• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM box2d top down wheel

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.
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);
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 by a moderator:
J

Jasnsathome

Guest
I feel really dumb at this point that I do not understand this if anyone can help.
 

Jezla

Member
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.
 
Top