How do I prevent sprites from clipping through barriers?

From the Asset Store
Build your map with these isometric objects and terrains
  • I followed the beginner platformer tutorial here on the site, and set up the Edge Markers to act as a barrier so when the enemy sprite touches it, it changes direction.

    Sometimes it works flawlessly during testing and sometimes the little bugger just walks right off the side of the platform, like it decided "Not today!" and just ignores the marker entirely.

    If you need to see a screenshot or demo or something let me know how I can do that (new to the forum). Any help is appreciated, it's really weird.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This can be caused by collision polygons. If your sprite has an animation playing and each frame has a different polygon or different position of the origin image point - then when animation frame changes, it may collide with the marker/wall, even if the sprite has already turned and started moving away from it. As a result, it immediately turns again and walks through the wall.

    The common solution is to use a separate sprite (simple invisible rectangle) for the collision box, and pin your animated sprite to it.

    Another option is to add a "cooldown" period. After colliding with the wall, ignore further collisions for this sprite for 0.5 seconds. You can use an instance variable "lastCollision", set it to time expression. And in "On collision" event check that lastCollision<(time-0.5)

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