Need Help Fixing Enemy AI

0 favourites
  • 8 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • So, i'm making a platformer game where there are enemies who switches sides whenever it hits a wall, the AI works fine when put on a solid platform like this

    but, when put on spikes like this, the AI seem to be broken. The enemy would continue walking in the same direction, even when it hits a wall. So it would be stuck in one place

    Here is the programming on my enemy

    The walls are made of a solid tilemap while the spikes are solid sprites with a triangular hitbox. Changing the spikes' hitbox to rectangular doesn't work. What could be the problem?

    Tagged:

  • Why do you have a condition "Is overlapping Spike at offset"?

    Two conditions "Has wall on the Left" and "Has wall on the Right" should be enough for this AI to work. Also, make sure that the origin image point is in the middle (horizontally) of the sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the condition "is overlapping spike at offset" is so that they would bump and change directions when they hit a spike. Not including them doesn't work, they just got stuck in one place despite having their origins on the middle. The problem also persists despite changing the origin of the sprite to the middle. Any ideas why?

  • they would bump and change directions when they hit a spike.

    But on your screenshot the enemy is walking on the spikes.

    Can you share your project file?

  • Ah, sorry, i was talking about a different enemy. Very well, i shall share my file. Download it here (don't worry, it's safe)

  • Try changing the collision polygon on the spike sprite to a rectangle. Also, I suggest increasing deceleration value for enemies and changing your events like this:

    .

    Note, that event 8 should come after the group "Wall detection". Otherwise the enemy will continue moving in the wrong direction this tick and may fall off the edge or get stuck somewhere.

  • it still doesn't work

  • What exactly doesn't work? It works perfectly fine for me.

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