Bouncing Enemies That Change Directions

This forum is currently in read-only mode.
  • I can't get this to work. If I try to rotate they get stuck/bounce off at random angles from the things they bounce off, if I try setangle they get stuck on the second bounce after working correctly the first time. I just want enemies that bounce back and forth and change direction every time they bounce.

    dropbox link to .cap file here:

    http://dl.dropbox.com/u/22863144/sailboatgame.cap

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did update the cap but noticed yours was saved in an earlier version so here's some code instead (only replace the collision event, I only added the private variable test so you could recognise where I mean)....

    Replace...

    On collision between enemy1 and terrain

    enemy1: Value 'Right' Equal to 1

    On collision between enemy1 and terrain

    enemy1: Value 'Left' Equal to 1

    WITH

    enemy1: overlaps Terrain : offset(2,0)

    enemy1: Value 'Right' Equal to 1

    enemy1: overlaps Terrain : offset(-2,0)

    enemy1: Value 'Left' Equal to 1

  • The offset idea is good but I'm still not sure how to get the enemy to bounce correctly. Setting angles doesn't seem to work, the simple bounce action doesn't work (although one of the enemies bounces in that case ???), and doing a rotation doesn't really work either.

  • Why not give the enemy ships the Ball behavior instead of the 8-direction?

  • That's a good idea. I tried it and it works OK but they bounce around in different directions. Is there a good way to constrain them to left/right or up/down (ie 90 degree angles) only?

  • In that case you could use the bullet behavior with a event "on collision with terrain" rotate 180 degrees CW.

  • The bullet thing worked great. Thanks!

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