"physics_apply_force" problem <SOLVED>

HayManMarc

Member
I'm playing around with physics and trying to get an object to move straight ahead. I'm using this bit of code:

Code:
var forward_x = lengthdir_x(8000, -phy_rotation);
var forward_y = lengthdir_y(8000, -phy_rotation);
physics_apply_force(x, y, forward_x, forward_y);
It moves the object, but causes it to turn slightly to the left. How do I make it so it moves straight forward?

For context, the object is a car viewed from the top.

Note: I'm hoping for a simple solution, as true realism (perfect driving sim) is NOT the goal.
 
their is a good change that the origin of the sprite and the center of mass are not aligned, try using this and see what happens

physics_apply_force(phy_com_x, phy_com_y, forward_x, forward_y);
 

HayManMarc

Member
I fixed it by adjusting the points in the collision shape. They were not very exact. (All I had to do was ask a question on the forum for the answer to dawn on me. Doh!)
Thanks for the reply, @JML. That may come in handy later. *thumbs up*

(actually, using "phy_com_x/y" may have been easier. lol)
 
Top