How do I get enemy to move to player in 90degree movement with bullet behavior?

0 favourites
  • 11 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hope everyone had a merry Christmas! Im back working on my project and was wondering how I could get my enemies to move in a 90 degree movements towards my player. My enemies keep moving in angles when going towards him.

    I have them move the way I want them to move in my wander state, moving in the degree of 0, 90, 180, and 270. But when it comes to targeting the player, they just cut across the screen to target him and not move in, 0, 90, 180 and 270 degrees towards him. How do I get enemy using the bullet behavior to move towards player in 0, 90, 180 and 270 degree movements?

    This is move my code I have for their wander state.

    This is the code I have for the enemy pursue state.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks so much! That's exactly what im trying to accomplish! I followed the coding but the enemy doesnt fully follow the player. They will go back and forth and follow the player, but they won't actually go up or down to fully go to the player...

    this is the coding of it

    in event 23, I changed the event to "Each enemy" instead of "Enemy on create". I tried both and a few other different event such as "Enemy on screen" and "pick all, enemy" but they dont seem to work.

  • Events 24 and 25 should run once, that's why I put them into "On created" event. I'm guessing in your case they are running on every tick, which causes this problem.

  • In the short example you shared to me, the bullets also uses everytick in your demo as well. So do I change that event then to something else for my project?

  • Events 24-25 on your screenshot need to be run once, either when enemies are created, or when they start chasing the player.

    Events 26-28 need to run on every tick.

  • Ah, I understand what you mean now. Thank you very much. It works now. I changed event 23 to trigger once, and now it works. I appreciate your help a lot.

  • No, don't use "Trigger once" with multiple instances! This will not work correctly.

    Move lines 24-25 into "Enemy on created" event, or inside the event where you set State="Pursue" for enemies.

  • Oh okay. But they are inside the "pursue" state event. When I run the code that way, they just stop moving. they will wander, but when it switches to pursue, they move to the bottom of the screen and just stay there...

    this is the code of event 24-25 being inside State= "Pursue"

    and when I put 24-25 event in like this, the enemies just ignores the player

  • You have lots of mistakes in this code..

    1. If you have multiple enemies, event 20 will not work correctly, because it will only check StateTimer of the first enemy. But it will change the state for all enemies.

    2. You should not deactivate the "wonder" group, because while some enemies may be in "pursue" state, others may still be in "wonder" state.

    3. Enemy On Created is not needed in this case. But if you are going to use it, it has to be a top-level event, don't nest it under other events.

    You need to change your code like this:

  • Thanks so much for your help and your time doing the coding events. it works now and also thanks for a better coding then what I had for my events.

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