How do I .. get Enemy to move back 3 places after collsion? C2

0 favourites
  • 6 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • Hi Community,

    I'm trying to get the enemy sprite to move back 3 places on collision. So, no matter the (angle of the Enemy), the enemy will bump player, then go back 3 places, then try hit player again.

    So, I'm trying: Every Frame - Enemy angle to player with a bullet motion.

    on collision, (this bit i get stuck).

    I've tried set position/Enemy.x/y - number :(

    Thanks,

    Roberto

  • Every frame, do you mean tick? How big is a 'place', are you on a grid? Set position would teleport the enemy, is that what you want or do you want more a bouncing off player type thing, for that you can set the angle to reverse of current angle for a bit then continue at the previous angle. For set position teleporting you have the right idea, just calculate which of the 4 directions it's heading in and you can add or subtract x,y based on the enemy direction.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sprite on collision with bumpinto

    repeat 3 times move sprite at angle angle(sprite.x,sprite.y,bumpinto.x,bumpinto.y) +180 speed to move (loopindex+1)*distancepermovementstep

    that might help, but if you are using a grid to move .. u might want to adjust the movement based on your grid system.

    if you have a bullet motion then you have bullet.angleofmotion and u can revert it to bullet.angleofmotion+180 which is opposite side of your current movement direction/angle.

    now if the above loop might not work or cause conflicts on how the movement is happening if used with bullet behavior.

    to adapt to bullet behavior you need to either disable the bullet behavior or change the repeat loop to change angleofmotion to angleofmotion+180

    then stop and revert back the angleofmotion if the movement is to be continued forward based on distance that is equal or greater 3x block size or step size that the sprite object that is reflecting has to move, from the bumpinto to sprite current position is a bit confusing but i hope it makes sense, is actually very simple.

  • Thanks guys,

    It's taking me a little longer to figure this out but you're suggestions are challenging me to think ;)

  • Thanks guys,

    It's taking me a little longer to figure this out but you're suggestions are challenging me to think ;)

    If you simply want it to bump back 3 times the size of your sprite, you could do something like this.

    This is presuming your sprite is 64 in width

  • Thanks sizcoz

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