How do I move object toward X without them overlapping

0 favourites
  • 8 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I have a top down view game with a player and an enemy.

    Enemy moves toward player using pathfinder but when it collides with the player, it stops.

    At this point, i don't want the enemy to overlap on top of player object.

    I've tried setting solid behavior on both objects but they still overlap.

    I've tried giving them physics but then when the enemy collides with the player, it pushes it around when i don't want them to be able to push each around.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make the destination the AI goes to, NOT the destination sprites (player) center. Make the point they go to actually 16 or 32 units away from the actual sprite.

    Find path to----> sprite.x-sprite.width. And sprite.Y-sprite.Height.

    This will put it diagonal under the target sprite.

    Hope I understood you correctly.

    If you want an example send me a private message. I have AI, and Pieces of AI that might help you out.

  • thank you for reply.

    enemies can approach the player from any angle, so if i follow the approach i would have to create many points around the player.

    i feel like there should be a better way to do this.

    I want it to also handle the case where there are multiple enemies surrounding the player and i don't want any of them overlapping each other.

  • kimtaein1

    set a variable "distance" to the enemy.

    every tick: set enemy.distance = distance(player.x,player.y,self.x,self.y)

    if enemy.distance > 100 --> path find...

  • Can't you just add condition along the lines of

    If player collides with target -------- player pathfinding movement STOP

    ?

  • Or

    negate(enemy is overlapping player) --> path find

  • There is some built in NO-overlap things with the 8-direction and platform behaviors IIRC. Just add the behavior, and see if they still overlap. I think they will try to push away from each other by default.

  • https://goo.gl/e6hRts (r215)

    using on collision stop the path movement.

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