Applying force to a falling object

Hello,

I am just playing around with the default project (Defold Logo). I have attached a dynamic collision to this game object which now continues to fall through the air.

Upon pressing the space bar I am applying a force to this object:

msg.post("go1", "apply_force", {force = vmath.vector3(0, 100, 0), position = go.get_world_position("#go1")})

I thought it would make the object go up but instead it spins clockwise. How can I apply a force to make the object go up and cancel out gravity.

Thanks.

The position argument is in local space. Try leaving that argument as nil, or vmath.vector3(0,0,0)

@sicher Perhaps we can clarify this?

@Mathias_Westerdahl,

Thanks for the response but leaving the value nil generates a runtime error and vmath.vector3(0,0,0) has the same affect.

Huh, I stand corrected. Could it be the force is specified in the game object’s parent space perhaps?
If you try:

msg.post("#collisionobject", "apply_force", {force=vmath.vector3(0, 100000, 0), position=go.get_position()})

Remember that the force is applied for a single frame. To get any kind of visible result you need to apply either a large force or a smaller force over many frames.

2 Likes