• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM box2d top down wheel

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.
Here is one of several attempts I have made unsuccessfully.
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);
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.
Last edited:


There is an asset on the Marketplace that is a conversion of that tutorial into gml. It's not perfect, but it's cheap and will show you how it works.