How do I make an enemy collide with itself.

0 favourites
  • 15 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Basically, I have an enemy sprite that moves to the player until they are 100 pixels away from eachother.

    It also has bullets, so when they are close enough, they begin to shoot at the player.

    But, since I have 3 of the same enemies, they go to the player but then they eventually go inside eachother, so there's 3 enemies in one pile. The bad thing about this is that when they begin to shoot, they instead shoot 3 bullets. So if you touch that one bullet, you lose 3 health.

    Here's the pic of it happening:

    Is there a way of making the enemies "bounce" away from eachother?

    I've tried making them solid, didn't work, then giving them a physics behaviour but making them immovable. Still didn't work :/

    Is there a way of colliding the enemies with themselves?

  • Anything?

  • System -> Pick nth Instance

    If 2 instances collide, picking instance 0 will pick the first instance and instance 1 will pick the 2nd instance

    ON collision Enemy with Enemy

    Pick instance 0 ... do whatever

    Pick instance 1 .. do whatever

  • System -> Pick nth Instance

    If 2 instances collide, picking instance 0 will pick the first instance and instance 1 will pick the 2nd instance

    ON collision Enemy with Enemy

    Pick instance 0 ... do whatever

    Pick instance 1 .. do whatever

    That's a start, but by colliding, I mean they can't go into eachother. Check the picture.

  • So using the above you could add actions to either one of the enemies in the collision, preventing the overlap.

    sending one of them temporarily in a different direction would do the trick, or increasing/decreasing the speed of one.

    It depends on what you would like to happen.

  • So using the above you could add actions to either one of the enemies in the collision, preventing the overlap.

    sending one of them temporarily in a different direction would do the trick, or increasing/decreasing the speed of one.

    It depends on what you would like to happen.

    How about this:

    It doesn't work but I think it's a start.

  • Hey, you simply use the platform behaviour combined with a solid behaviour. Check part 4 of my videos: youtube.com/watch

    Your idea of moving them apart is a bad idea.

  • Hey, you simply use the platform behaviour combined with a solid behaviour. Check part 4 of my videos: Your idea of moving them apart is a bad idea.

    It *kind of* works. It's just that sometimes they teleport around for some reason.

  • There isn't an angle between corrupscepticeye and corruptscepticeye when it is the same instance.

    You pick an instance in your event, so in your action both are that instance.

  • > Hey, you simply use the platform behaviour combined with a solid behaviour. Check part 4 of my videos: Your idea of moving them apart is a bad idea.

    >

    It *kind of* works. It's just that sometimes they teleport around for some reason.

    Try the condition: Overlapping by offset (5,5). This might fix the teleport problem. Let me know if it did! Or disable the Platform behaviour as soon as it detects a collision. I think that's actually the better solution for what you need.

  • >

    > > Hey, you simply use the platform behaviour combined with a solid behaviour. Check part 4 of my videos: Your idea of moving them apart is a bad idea.

    > >

    >

    > It *kind of* works. It's just that sometimes they teleport around for some reason.

    >

    Try the condition: Overlapping by offset (5,5). This might fix the teleport problem. Let me know if it did! Or disable the Platform behaviour as soon as it detects a collision. I think that's actually the better solution for what you need.

    Yeah, it didn't work

    I'll just use one enemy but give it a higher rate of fire.

  • maybe use my solution but as soon as it detects a collision, you pin the object..i didnt try this but it might actually work

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a quick example to show how to stop them going into each other.. sure, they bounce off each other (and that's probably what you don't want) but it should give you an idea of how to use pick nth instance..

    You can easily replace the collision with overlapping.

    mutliple instances

  • There are 3 things needed:

    Platform behavior (on enemies)

    Solid behavior (on enemies)

    a collision polygon larger than the actual enemy.

    I made a quick capx example, you can get it here:

    https://onedrive.live.com/redir?resid=C2D3604A25210B53!3504&authkey=!AG5beWa9UtR8lgs&ithint=file%2ccapx

    Good luck.

  • Thanks guys, I'll try them all out later.

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