#Cinematic

1 messages · Page 1 of 1 (latest)

jaunty helm
#

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...

solid pollen
#

vector from yaw x and from pitch y should work and also you should use the distance to change the vector length, if the vector is like 1200 blocks at length 1, set vector length to 1/1200 so its one block per offset (i assume that would work otherwise im not sure)

cyan ferry
#

you can set the pitch/yaw of a location then teleport the player to the location.

#

you can find the initial and final yaw/pitch, and then take n steps of theta/n to get there

#

where theta is the difference in angles

jaunty helm
jaunty helm
jaunty helm
#

I will try that tmrw

solid pollen
#

i mean u can just do teleport x to {_ent}'s location ~ {_v} no? because the vector already is moving by the vector between start and end I wasn't quite sure why you did that

jaunty helm
# solid pollen i mean u can just do teleport x to {_ent}'s location ~ {_v} no? because the vect...

Im making it so the player would spectate the entity because 1. Then they cannot rotate the themselves without me needing to cancel another event; 2. The teleportation of a block display is smoother. But yeah, doing it like teleport {_ent} 0.1 blocks in front of {_ent} ~ {_v} is sort of one thing. Now it get's teleported towards the second location, but the yaw doesn't change. So I will probably have to implement something like x8ight said...

jaunty helm
#
function cinema(p: player, t: integer, loc1: location, loc2: location):
    set gamemode of {_p} to spectator
    summon block display at {_loc1}:
        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 standard length of {_v} to 0.1
    set spectator target of {_p} to {_ent}
    set {_dm} to {_d} * 10
    set {_skip} to round(1 / ({_t} / {_dm}))
    set {_yd} to ((yaw of {_loc1}) - (yaw of {_loc2})) * -1
    set {_pd} to ((pitch of {_loc1}) - (pitch of {_loc2}))
    if {_skip} > 1:
        set {_w} to 1
    else:
        set {_w} to {_t} / {_dm}
    loop {_dm} times:
        set {_loc} to location of {_ent}
        add {_yd} / {_dm} to yaw of {_loc}
        add {_pd} / {_dm} to pitch of {_loc}
        teleport {_ent} to {_loc} ~ {_v}
        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

I edited it to this

#

And, it kind of works.... Just that the yaw sometimes is funny and goes the other way :p