Problem with enemy movement

From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • I'm trying to achieve enemy movement with the following rules:

    Movement is restricted to a 32x32 grid.

    - If the enemy is in the same row as the player it should turn left when the player is to its left or right when the player is to its right

    - If the enemy is in the same column as the player it should turn up if the player is above it or down when the player is below it

    - If both conditions are not true the enemy checks its distance to the players column and row and turns towards the player on the axis where the distance is closer.

    This is what I have:

    This works basically but not consistent. They mostly turn only when the player crosses them but not when skelAbsDistX becomes smaller then skelAbsDistY. Also I start with 2 enemies on the screen and then spawn a new enemy every 3 seconds. The first two enemies immediately start moving, the others don't, even when I set the initial value for their direction variable to "right". They only move when I cross them and sometimes just crossing is not enough, I have to move on their row or column for 1-2 tiles.

    Any idea why this happens? Maybe the random spawning and the tile movement conflicts because they don't spawn correctly in the grid?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)