How do I stop my enemy from continuing on after collision

Get help using Construct 2

Post » Wed Jan 14, 2015 12:21 pm

Hi,

I am having an issue where when my sprite hits a collision point it seems to keep going and ignoring my speed changes. So basically when my sprite hits the right boundary wall, I set the animation to mirrored and change the speed to a negative number. When it hits the left boundary wall, I do the same in reverse. The animation works but not the direction. It keeps on moving.

It seems to work one way but not the other. I have extracted my code and attached my capx as an example from my game.

If someone could take a quick look and offer their expert advice, I would appreciate it.

Thanks.
You do not have the required permissions to view the files attached to this post.
B
6
S
2
Posts: 38
Reputation: 567

Post » Wed Jan 14, 2015 12:50 pm

Instead of modifying the speed to negative or not, you should rather set the angle of motion for the bullet behavior.
0 to go right, 180 to go left.

Also in event 5 adding a "Else" condition to make sure you are not piling conditions/events in the same tick. They could happen so fast you wouldn't know it.
At least with the "Else" you are making sure it is either event 4 OR event 5 that is executing when all the conditions are met and not both in a row.
You do not have the required permissions to view the files attached to this post.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,313
Reputation: 71,094

Post » Wed Jan 14, 2015 3:44 pm

What I do is set two borders one left_border & right_border

Give the player a bullet behaviour OR a platform your choice both work the same...

Player on collision with right_border simulate control pressing left set player_image mirrored

Player on collision with left_border simulate control pressing right set player_image not mirrored

(this would be for platform)

for bullet just set angel of motion instead
Need Sprites For Your Next Project?
100% Vector Animated Sprites
B
8
S
2
Posts: 170
Reputation: 1,086

Post » Thu Jan 15, 2015 1:21 am

Thank you Kyatric and desjardins2014. I will take a look at this tonight when I get home. They are both very useful tips and suggestions so will look at them both and might swap around depending on the scenario in the game.

Cheers Guys,
B
6
S
2
Posts: 38
Reputation: 567

Post » Thu Jan 15, 2015 2:36 am

Just a quick update and thanks again. I have quickly checked the capx file that Kyatric posted and this is exactly what I was looking for and makes more sense with the else. I will still look at the button simulation tonight as this sounds interesting.

Cheers,
B
6
S
2
Posts: 38
Reputation: 567


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 10 guests