PDA

View Full Version : Change x and y velocity based on player facing angle?


Aerotactics
17/08/2014, 06:22 PM
I don't know what to do here, I have 2 portals. When a player enters the first portal, their velocity is saved and given to them on the exit portal, but the exit portal changes facing angle, while the velocity continues from the entrance portal. Is there a way to get the facing angle of the exit portal, then set their x and y velocity to exit straight from the exit portal? My assumption is that it's a math problem, but IDK where to start.

Pottus
17/08/2014, 06:26 PM
I'm not sure but I know Nero3D would know what to do but I'm pretty sure atan2() is involved somewhere here.

Virtual1ty
17/08/2014, 06:32 PM
You're trying to recreate the game "Portal" right? Unfortunately I never played it or heard about it so I dunno what you mean by "changing player facing angle on exit portal" but if those portals are like you "drop from a ceiling onto a platform", then the only way I guess would be getting that platforms landing XYZ and determine the angle difference (actually coordinates to get the angle) from the portals XYZ from where you start to "drop" and the platforms XYZ where you land. I don't believe there's any other way AFAIK.

Aerotactics
17/08/2014, 06:47 PM
You're trying to recreate the game "Portal" right? Unfortunately I never played it or heard about it so I dunno what you mean by "changing player facing angle on exit portal" but if those portals are like you "drop from a ceiling onto a platform", then the only way I guess would be getting that platforms landing XYZ and determine the angle difference (actually coordinates to get the angle) from the portals XYZ from where you start to "drop" and the platforms XYZ where you land. I don't believe there's any other way AFAIK.

Yes, I am attempting to recreate the game in SAMP. I have only seen it done once before, and it wasn't based off the game as I recall. I already know my attempt is in vain, but I want to see how far I can get.

Pottus
17/08/2014, 09:39 PM
Nero is on now, can you look at this Nero_3D ?

Nero_3D
18/08/2014, 02:13 PM
The truth is I can't help here, I have no experience with rotations of objects

I think if you want to solve that problem you should get the difference of the rotations from both objects and rotate the incoming vector from the first portal with rotation matrixes to match the exit portal

Aerotactics
18/08/2014, 05:29 PM
That sounds about right. I'll get to it.