J
Jasnsathome
Guest
I am trying to make a top down wheel so that it is limited in its movement sideways. I have found an example here. The section labelled "Killing lateral velocity" is what I am attempting to do.
http://www.iforce2d.net/b2dtut/top-down-car
Here is one of several attempts I have made unsuccessfully.
I'm having trouble with all the vector stuff if anyone could give me a short explanation on how to do this I would appreciate it.
http://www.iforce2d.net/b2dtut/top-down-car
Here is one of several attempts I have made unsuccessfully.
Code:
var r = phy_rotation * -1; //tires forward angle
var m = phy_mass;
var lx = phy_linear_velocity_x;
var ly = phy_linear_velocity_y;
var vx = lengthdir_x(lx, r + 90); // sideways angle
var vy = lengthdir_y(ly, r + 90);
var d = dot_product_normalised(vx, vy, lx , ly);
phy_linear_velocity_x += lengthdir_x(d, r - 90);
phy_linear_velocity_y += lengthdir_y(d, r - 90);
Last edited by a moderator: