I have made a little function with some math to make a player have a smooth cinematic cutscene:
function cinema(p: player, t: integer, loc1: location, loc2: location):
set gamemode of {_p} to spectator
summon block display at {_loc1}:
make {_p} ride entity
set display block data of entity to air
set display teleport duration of entity to 2
set {_ent} to entity
set {_d} to distance between {_loc1} and {_loc2}
set {_v} to vector between {_loc1} and {_loc2}
set spectator target of {_p} to {_ent}
set {_dm} to {_d} * 10
set {_skip} to round(1 / ({_t} / {_dm}))
if {_skip} > 1:
set {_w} to 1
else:
set {_w} to {_t} / {_dm}
loop {_dm} times:
teleport {_ent} 0.1 blocks in front of {_ent}
if {_skip} > 1:
if mod(loop-iteration, {_skip}) = 0:
wait "%{_w}% ticks" parsed as timespan
else:
wait "%{_w}% ticks" parsed as timespan
reset spectator target of {_p}
kill {_ent}
set gamemode of {_p} to survival
But the issue is that if I make a different yaw/pitch in the second location, that won't change anything, because currently, the second location is just for the distance. Is it possible to use something like vectors to also smoothly change the yaw pitch? I have tried doing(as you can see) set {_v} to vector between {_loc1} and {_loc2} and then I do teleport {_ent} 0.1 blocks in front of {_ent} ~ {_v}, but the issue is that then it teleports you a LOT of blocks more than intended. Like, from 0 0, you end up in the 5 thousands...