How do I prevent an object from clipping into the wall?

0 favourites
  • 6 posts
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • I am making a top-down shooter, and I have a last seen object the player leaves when he gets out from the enemy's LOS. When the enemy sees this object, the enemy walks on it. But this usually takes place near the wall. How do I get the enemy to go into the exact place without going inside the wall? Quickly too, I don't want the enemy to seem like it's calculating a straight path.

  • If the enemy is going inside the wall, check the size of your collision cells for the path finding behaviour. I assume you're using the path finding behaviour for moving the enemy to this "last seen object" you have?

    Also check the collision bounds of the wall objects and the enemy character too, and make sure they're good.

    To make the enemy go exactly on the object - check for a close distance (proximity) on the object... once you have this close distance (after using path finding) then turn path finding off and use "moveto" behaviour or some other movement method to go straight to final position. The path finding will work when the enemy is far away (so it will avoid walls and such) but then move to the exact place once within your defined distance (10-20 pixels maybe?).

    ~Sol

  • If the enemy is going inside the wall, check the size of your collision cells for the path finding behaviour. I assume you're using the path finding behaviour for moving the enemy to this "last seen object" you have?

    Also check the collision bounds of the wall objects and the enemy character too, and make sure they're good.

    To make the enemy go exactly on the object - check for a close distance (proximity) on the object... once you have this close distance (after using path finding) then turn path finding off and use "moveto" behaviour or some other movement method to go straight to final position. The path finding will work when the enemy is far away (so it will avoid walls and such) but then move to the exact place once within your defined distance (10-20 pixels maybe?).

    ~Sol

    I didn't use the path finding behavior, because it doesn't work. The first time the enemy is assigned to find a path, he does and moves like 30 pixels and then stops. Second time he just keeps calculating.

  • The path finding behaviour works perfectly... but perhaps you are making some mistakes with it's use. It can be tricky to get it working as expected if you haven't had much experience with it. I don't use it often myself - but I've had some successful experiments with it in the past.

    The main things I would suggest to be careful of, is telling the behaviour to calculate the destination path too frequently. Once every 1-2 seconds is usually more than enough unless you have moving obstacles or incredibly fast moving objects. A common mistake that people make it getting the path to calculate every tick or every 0.2 seconds or similar.

    Another common mistake is having cell sizes that are not an appropriate sizing for the design of sprites and game environment. Having cells that are too big or too small can make weird things happen.

    Moving solids CAN pose problems, but there are even work-arounds and methods for dealing with this also.

    I suggest you try path finder again, and use a simpler movement method once close to your point of "last seen".

    ~Sol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The path finding behaviour works perfectly... but perhaps you are making some mistakes with it's use. It can be tricky to get it working as expected if you haven't had much experience with it. I don't use it often myself - but I've had some successful experiments with it in the past.

    The main things I would suggest to be careful of, is telling the behaviour to calculate the destination path too frequently. Once every 1-2 seconds is usually more than enough unless you have moving obstacles or incredibly fast moving objects. A common mistake that people make it getting the path to calculate every tick or every 0.2 seconds or similar.

    Another common mistake is having cell sizes that are not an appropriate sizing for the design of sprites and game environment. Having cells that are too big or too small can make weird things happen.

    Moving solids CAN pose problems, but there are even work-arounds and methods for dealing with this also.

    I suggest you try path finder again, and use a simpler movement method once close to your point of "last seen".

    ~Sol

    I set the cell size from 30 to 10, and now it works almost perfectly. Thanks!

  • Sweet. I'm glad that worked for you!

    ~Sol

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