Page 1 of 1

Calculate Vector by giving angles and velocity

Posted: Sun Apr 01, 2018 6:27 pm
by decompile
Hey,

as stated in the title, I need a function which returns me a Vector with the given angles and velocity.

Its similar to creating a trigger_push trigger, where you enter the "pushdir" and speed, for example "0 -90 0" and "1250".

I think it would look most likely like (x, y, z) = (0, -1250, 0) but how could I calculate it for weird angles, like "30 0 45" angle and "1330" speed.

Thanks

Re: Calculate Vector by giving angles and velocity

Posted: Sun Apr 01, 2018 11:14 pm
by Ayuto
I think you are looking for Player.view_vector or at least the math of it. Then you normalize the result and multiply it with the speed.

Edit: You can also directly set the length of the view vector.

Syntax: Select all

vec  = player.view_vector
vec.length = 1250