How do I cause a moving sprite to stop on impact?

Get help using Construct 2

Post » Mon Jul 20, 2015 12:25 am

Hello my fellow Construct users,

I'm creating a game where I need to make projectiles (such as missiles) move and then explode on impact. My current problem is that once the missile makes impact with the intended target, the explosion animation plays but it keeps moving in the same trajectory of the missile before it exploded.

I realize that this may sound a bit complicated so I'll try and elaborate a bit more. I have a target on the ground, and I want a missile to hit it, but once the missile hits, I want it to trigger the explosion animation while staying in the position it was in upon impact.

I really hope this makes sense, and thank in advance!
B
5
Posts: 12
Reputation: 249

Post » Mon Jul 20, 2015 1:00 am

Have you put the explosion's animation in the sprite of the missile?
Image Image
B
25
S
14
G
136
Posts: 876
Reputation: 71,005

Post » Mon Jul 20, 2015 4:59 pm

Yes I added all necessary animations to the sprite of the missile. However, the missile which is supposed to be flying towards the target, once it makes impact with the aforementioned target, the explosion animation plays but then the explosion flies off screen.
B
5
Posts: 12
Reputation: 249

Post » Mon Jul 20, 2015 6:38 pm

*missile on collision with wall(or object you want):
---missile set speed to 0
---missile set acceleration to 0 (if missile.acceleration>0)
---missile play animation "explosion" (play from beginning)
*missile on animation "explosion" finish:
---missile destroy

or

add new sprite with explosion only then
*missile on collision with wall(or object you want):
---missile spawn sprite"explosion" at imagepoint 0
---missile destroy
*"explosion" on animation finish: explosion destroy
Image Image
B
25
S
14
G
136
Posts: 876
Reputation: 71,005

Post » Mon Jul 20, 2015 10:26 pm

Thank you so much! You're awesome!
B
5
Posts: 12
Reputation: 249


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests