How to add force to game object so it's move's in projectile path?

Hi, I have a game object (Frog). when I touch or click the frog it needs to jump in the x-axis. Please help me with hints so I can solve this problem.
frog

Here’s an Angry Birds like example game I made a few years ago:

Code: GitHub - britzl/throwacrow: Defold example of a slingshot style physics game
Demo: Throw a Crow 0.1

Relevant line where a force is applied:

Direction is a vector pointing in the direction the force should be applied. Examples:

-- vector pointing straight up in the air
vmath.vector(0, 1, 0)

-- vector pointing horizontally to the right
vmath.vector(1, 0, 0)

-- vector pointing at 45 degree angle up and right
vmath.vector(1, 1, 0)

The force applied to the object is the direction multiplied by the magnitude. The force is applied to the center of the collision object.

msg.post("#collisionobject", "apply_force", { force = direction * 950 * go.get("#collisionobject", "mass"), position = go.get_world_position() })

2 Likes

Thank you for your help :))