#How to conserve momentum through respawns but change the direction of the momentum

111 messages · Page 1 of 1 (latest)

chilly parcel
#

basically im making some portals- or well redoing the cv1 code and i want to be able to keep the momentum but change the momentum direction according to the direction the exit portal is facing, any help?

fathom olive
#

Don't use respawn, use set pos and velocity set.

solemn mesa
#

get the entrance velocity and invert it on the way out

fathom olive
#

this is def a Ctrl + F moment.

chilly parcel
solemn mesa
#

get velocity then subtract it from itself twice

chilly parcel
#

so this would work per direction?

fathom olive
#

Welp, hopefully CC finds this and links the proper threads. This is something that's already been answered. I couldn't find it, I'm dumb. 😛

solemn mesa
#

so velocity - velocity - velocity

chilly parcel
#

alright lemme try

solemn mesa
fathom olive
chilly parcel
#

ive got static portals luckily for me, i wasnt about to code a portal gun tbh

dusky cypress
#

Rotate the player rotation by inverse of entry portal rotation then rotate that by exit portal rotation, set transform the player with that as rotation if you want the player to face the right direction (pretty sure that's how)

chilly parcel
dusky cypress
#

Speed is just player velocity magnitude

#

Might have said something wrong, tell me if it doesn't work

chilly parcel
solemn mesa
#

T55Milk is better at this than i am so go with their idea

dusky cypress
#

Get local player>get rotation
Get entrance portal>get rotation>quaternion inverse
Get exit portal>get rotation

chilly parcel
dusky cypress
#

Rotate 1 by 2 then then the result by 3

chilly parcel
dusky cypress
#

Inverse of entrance

chilly parcel
#

so just by the inverse of the entrance?

dusky cypress
#

Then by exit

chilly parcel
#

this is gonna be me gfetting to dumber levels, how again?

dusky cypress
#

What

chilly parcel
#

i have no clue what im doing is what im saying, this is honestly my first time screwing around with set rotations

#

like all i really need is just like the x and z axis kept for velocity

dusky cypress
#

Just do everything I said

#

Result of 3 goes into set transform

chilly parcel
#

what chip am i using for rotation? there isnt a result? or am i using an add chip or sum?

dusky cypress
#

Rotate 1 by 2 and the result by ,3

#

Then set transform

chilly parcel
dusky cypress
#

Multiply

chilly parcel
#

ahh

dusky cypress
#

I think

#

Try multiply

chilly parcel
#

it worked!

#

thank you

#

sorry for hitting roadblocks a couple times

#

wait

#

hold on

#

so ive got a portal at a | position and a portal at a _ position, i drop from top to bottom and its not pushing me forward

dusky cypress
#

So that's rotation

#

Now do the same with velocity then add velocity

chilly parcel
#

hm okay

#

so local player velocity times itself?

#

or legit the same

dusky cypress
#

Legit do the same

#

but since velocity is a vectorrrr

#

hmmmm

#

Either convert it to quaternion

#

Or try with vectors idk if it works

#

Oh nvm it won't work

#

Just make the velocity as a quaternion

chilly parcel
#

alright, i still have a respawn chip going, should i still use that?

dusky cypress
#

Nah

#

Set transform

chilly parcel
#

what do i connect the pos input too again?

dusky cypress
#

The pos you want the player to be

#

when he enters

chilly parcel
#

issue

#

im set 90 degrees anticlockwise from the area i want to be flung, also no flinging occurs

chilly parcel
shrewd nymph
#

The entire thread covers relative velocities and directions for entering and exiting portals

dusky cypress
#

Yeah couldn't find it

shrewd nymph
chilly parcel
#

uhfue thanks

dusky cypress
#

@shrewd nymph do you always need a variable?

dusky cypress
#

So set variable then set rotation?

shrewd nymph
# dusky cypress So set variable then set rotation?

Save the velocity direction
Save the look direction

  1. Rotate both by the inverse of the entrance portal rotation
  2. Rotate both by the rotation of the exit portal rotation
  3. Reflect both by the forward direction of exit portal
#

You will need a third variable if you want to keep relative position, which you probably should

#

Relative position is different, you cant just rotate it back and forth

fathom olive
dusky cypress
#

Does it work with player rotation?

shrewd nymph
#

tbh i might just make a "Portal relativity board" because its very confusing math

#

well, not to me, but

dusky cypress
shrewd nymph
dusky cypress
#

Oh

shrewd nymph
#

Or screenmode users

dusky cypress
#

yeah true

#

They should make a camera rotation thing tbh

shrewd nymph
#

No, they shouldnt, ever

dusky cypress
#

oh

#

Why

shrewd nymph
# dusky cypress Why

Rotating the camera would be disorienting as shit, and like I said, wouldn’t make sense

shrewd nymph
#

See, for screenmode, it makes sense to be able to their look direction (No roll)

For VR, it only make sense to set their Y axis rotation, as anything else would rotate the camera in weird ways

#

But configuring the roll on either of those is a stupid idea

dusky cypress
#

Yeah true

chilly parcel
#

im obviously missing something

#

as well it doesnt take the down fall velocity and convert it

#

if i enter the bottom portal from the left side it does work

#

thats it

#

also is DEF speeding the player up

#

so if im falling down into the portal i dont gain any forward velocity out of the exit portal

#

the code in question btw

#

so the vec3 var is now in the player entered port, when excu it sets vel

sour elm