Calculate Vector by giving angles and velocity

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Calculate Vector by giving angles and velocity

Postby decompile » Sun Apr 01, 2018 6:27 pm

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
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Calculate Vector by giving angles and velocity

Postby Ayuto » Sun Apr 01, 2018 11:14 pm

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 36 guests