# Throwing dynamic objects (SOLVED)

**URL:** <https://forum.defold.com/t/throwing-dynamic-objects-solved/2923>\
**Category:** Questions\
**Created:** [September 14, 2016, 8:24am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923 "2016-09-14T08:24:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fill.freeman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/fill.freeman/32/2074_2.png) [@fill.freeman](https://forum.defold.com/u/fill.freeman)\
**Post date:** [September 14, 2016, 8:24am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/1 "2016-09-14T08:24:42Z")

</div>

I am a little confused with Defold’s physics.

I am trying to create a catapult that throws some blocks.  
Now, there is a kinematic bar and spawning dynamic block, laying on it.

I rotate the bar (via go.animate), trying to throw a block, but it does not work.

I expect, that during rotation, dynamic object gets some inertia to start flying. But it seems, that when rotation finished, block did not have any forces (except gravity).

There is a gif, to show it:  
 ![](https://forum-defold.b-cdn.net/uploads/default/original/2X/2/26c65ca04b64dfce2c43ff406230af2a4fb6ca3a.gif)

My question is:  
Is it normal in defold? Or I do something wrong?

As a workaround, I send apply\_force when getting collusion\_point\_response message. But I do not like result.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [September 14, 2016, 8:46am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/2 "2016-09-14T08:46:56Z")

</div>

Defold uses box2d so most resources related to it would be helpful.

You should add an extra rectangle to your swing collision so that it’s more like a boot or L shape at the end with the tip pointing outward to act as a kind of catch. Try that first and see if it helps. Second test spheres/circles instead of rectangles to throw.

---

<div class="post-metadata">

**Author:** ![Ragnar\_Svensson](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@Ragnar\_Svensson](https://forum.defold.com/u/Ragnar_Svensson)\
**Post date:** [September 14, 2016, 8:48am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/3 "2016-09-14T08:48:57Z")

</div>

We use Box2d so [this](http://www.emanueleferonato.com/2012/05/11/understanding-box2d-kinematic-bodies/) might help. I think the key problem is that box2d only does _separation_ between the dynamics and kinematics, so it’s not a real transfer of kinetic energy. As you can see from the example in the link, the dynamic balls are separated from the kinematic, rather than bouncing off. In some instances they in fact do bounce off, I wonder if that has to do with a particularly “deep” penetration of bodies in that case.

---

<div class="post-metadata">

**Author:** ![fill.freeman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/fill.freeman/32/2074_2.png) [@fill.freeman](https://forum.defold.com/u/fill.freeman)\
**Post date:** [September 14, 2016, 10:58am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/4 "2016-09-14T10:58:20Z")

</div>

Thanks for replays and ideas.

I found a couple good tutorials how to create a catapult in Box2d, but they are not suite for Defold. In those tutorials ([here](http://www.emanueleferonato.com/2010/04/07/real-world-catapult-prototype-using-box2d/) and [here](https://www.raywenderlich.com/4756/how-to-make-a-catapult-shooting-game-with-cocos2d-and-box2d-part-1)) we must use Revolt joint, and customize motor speed and so on. But as I found in the [forum](https://forum.defold.com/t/creating-a-physics-joint-between-two-or-more-physical-objects/1147), Defold is not support them yet.

---

<div class="post-metadata">

**Author:** ![Ragnar\_Svensson](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@Ragnar\_Svensson](https://forum.defold.com/u/Ragnar_Svensson)\
**Post date:** [September 14, 2016, 11:08am UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/5 "2016-09-14T11:08:41Z")

</div>

Yes, that’s unfortunately true. Feel free to add a feature request of what’s missing.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [September 14, 2016, 12:33pm UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/6 "2016-09-14T12:33:52Z")

</div>

I managed to create a catapult with the following setup:

 ![](https://forum-defold.b-cdn.net/uploads/default/original/2X/2/2f00fee910b02a1f9cf21f982bdf6281d9013b06.png)

Everything except ground and joint are dynamic.

---

<div class="post-metadata">

**Author:** ![fill.freeman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/fill.freeman/32/2074_2.png) [@fill.freeman](https://forum.defold.com/u/fill.freeman)\
**Post date:** [September 14, 2016, 1:25pm UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/7 "2016-09-14T13:25:33Z")

</div>

Wow! Great!

Unfortunately, I am at work, so cannot try to implement a dynamic arm, to test this approach. 😄

Anyway, How does it suppose to activate? Applying a force to the right side of the arm?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [September 14, 2016, 2:18pm UTC](https://forum.defold.com/t/throwing-dynamic-objects-solved/2923/8 "2016-09-14T14:18:17Z")

</div>

> [@fill.freeman](#):
>
> How does it suppose to activate? Applying a force to the right side of the arm?

Yes, I did like this:

```
msg.post("#collisionobject", "apply_force", { force = vmath.vector3(0, -100000, 0), position = pos + vmath.vector3(100, 0, 0) })

```

But you should probably also take into account the rotation of the arm to always apply the force perpendicular to the arm.
