Set vector momentum and calculate x and y values according to the new magnitude

12 views
Skip to first unread message

Henri Lämsä

unread,
Oct 7, 2019, 4:49:59 AM10/7/19
to excaliburjs
Hi,

I find using actor acceleration and velocity quite useful. Only problem seems to be that I can't set vector momentum/length. I need to do it by scaling or setting x and/or y values. I would find it useful if I could set vector length and excalibur would calculate the new x and y values for the vector. For example, I have a space ship actor and when Up-key is pressed acceleration is increased. I would like to check the maximum velocity for the ship. I can do it calling vel.magnitude(). But if acceleration would increase the velocity over maximum I would like to set the magnitude to the maximum velocity but it is not possible very easily. I can do it though by calculating the x and y values according to the new magnitude but it would be easier if excalibur would do it for myself. I think it might be quite commonly used feature. Not a big bad but would be nice to have :)
Reply all
Reply to author
Forward
0 new messages