How do I stop my enemy from continuing on after collision

0 favourites
  • 5 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • 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.

  • 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.

  • 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

  • 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,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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,

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)