How do I make a cannon fire a cannonball with momentum?

Get help using Construct 2

Post » Mon Jul 06, 2015 6:46 pm

I am looking for a way for a click to cause a cannon to fire a cannonball that has momentum?
B
5
Posts: 25
Reputation: 277

Post » Mon Jul 06, 2015 9:03 pm

You'll have to be more specific with what you mean by momentum. If you use the bullet behavior on the cannonball it will move on it's own. You could use the physics behavior instead to make it be able to interact with other physics objects.
B
94
S
33
G
118
Posts: 5,392
Reputation: 75,845

Post » Mon Jul 06, 2015 10:22 pm

This may help..not sure though. :D I made a capx file but it won't let me post it because i have no reputation. Sorry!
B
21
S
6
Posts: 59
Reputation: 1,387

Post » Tue Jul 07, 2015 11:35 am

When the mouse is clicked i want the cannon to fire a cannonball at a certain velocity and for it to have physics. How would I do this?
B
5
Posts: 25
Reputation: 277

Post » Tue Jul 07, 2015 11:54 am

Well you add the physics behavior to the object that the cannon fires(lets call it cannonball) and then you have events:
Event : on cannon touched(or tapped, or clicked, etc.)
Actions: cannon spawn object cannonball on layer XX
cannonball apply physics force XX at angle cannon.angle + XX

And just replace the XX's with the values you want.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Jul 07, 2015 12:51 pm

But the angle is where the cannon is facing because it follows my arrow so?
B
5
Posts: 25
Reputation: 277

Post » Tue Jul 07, 2015 1:20 pm

If you make the cannon ball a "bullet" using the bullet behaviour you can set the gravity.

https://www.scirra.com/manual/90/bullet

I guess that's what you mean?'

I got help with a similar problem in this thread before. Maybe this can help you out.

https://www.scirra.com/forum/viewtopic.php?f=147&t=148511
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,055
Reputation: 14,044

Post » Tue Jul 07, 2015 1:27 pm

FlameFoxx wrote:But the angle is where the cannon is facing because it follows my arrow so?


That is why I said replace the XX's with the values you want. In this case(if I understand you question correctly) the expression should be:
cannonball apply physics force XX at angle cannon.angle + 90
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Jul 07, 2015 4:29 pm

I've done it, thanks guys.
B
5
Posts: 25
Reputation: 277


Return to How do I....?

Who is online

Users browsing this forum: Karpakis and 10 guests