# How do I create this physics which affects...

0 favourites
• 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
• Hi everyone,

How to create a physics where the cannon shooting affects the cannon base and wheels movements like in the image below.

Now I know pinning the base obj to the cannon and physics applied. But how does the wheel rotates

• In theory if your objects have the correct mass, you can just apply the same force on the cannon as the cannonball, but at the opposite angle.

• I don't understand clearly. I actually need something like the sample game from this post.

parabola-tracjectory-tracing-with-physics-box2d_t77802?&hilit=trajectory&start=20

This sample game by JohnnySix

http://www.johnnysix.net/games/ParabolaTank/ - the cannon responds for the shooting pressure and angle and also the wheel spins.

Thanks JohnnySix for this wonderful reference

• I tried what I said before and it worked. Are you thinking of something different? What they were talking about in that thread was parabola movement, not 'recoil'.

Here's an example:

on mouse clicked:

・　create object "cannonball"

・　apply impulse 1 to cannonball at angle(cannon.x,cannon.y,mouse.x,mouse.y)

・　apply impulse 1 to cannon at angle(cannon.x,cannon.y,mouse.x,mouse.y) + 180

This works with some changes to the mass of both objects.

• Thanks mate....I will try what u said as soon as I reach home........

By the way about that thread i just wanted you to understand what I am looking for by that sample game in that thread and not that entire thread.

You can see the cannon moves based on the pressure and also the wheel spins.

• As for the wheels, it's as simple as don't use pin behavior. Unfortunately it conflicts with physics. For a wheel though you can just set a physics joint (it's an action). You can try with the different types of joints, that should fix any conflicts.

• Could u post a sample capx mate?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Here you go, have a look at the capx, the key for this sample to work is the ratio between the "Ball" density and the "Base" density, so applying the same impulse(inverted) to both of them gives a diferent effect (action/reaction).

Edit: the wheels are just round objects attached by a joint to the base, so when they suffer from the impulse they spin without any other worries.

• Thanks mate. I see what you have done there. I made changes and checked how both impulse works and how the joint works for the wheel.

Thanks a lot for the help caiorosisca and Sumyjkl

• 9 posts