How do I make enemy rotate to my player properly?

0 favourites
  • 4 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello Everyone.I'm trying to set an enemy behavior. My enemy "Wizard" is normally roaming between 2 blocks and while he's going right he looks to right and while he's going left he looks to left. And if I get close to wizard (300 pixel) , It stops and throw me a fireball every 2 seconds.Everything works fine.The only problem I have is no matter what I tried I couldn't manage this situation:

    1:When I'm close to wizard, Wizard should look towards me

    2:When I'm getting far away, wizard should continue to move as if I never got close.

  • "System compare two values" or "System evaluate expression" doesn't pick object instances! So if you have multiple enemies, it will only evaluate the distance to the first enemy instance. You need to use LineOfSight behavior instead.

    For each Wizard
    .. Wizard has LineOfSight to Player : fire at player
    .. Else : continue patrolling
    

    You can use "System pick by evaluate" condition to pick by distance, but the LOS behavior is a better choice.

  • Thanks for the help.It was extremely useful.But I have another problem. İf the enemy has LOS I want it to look the direction of my enemy which I try to manage it with mirrored or not mirrored condition.But when there is no LOS, I want to set my wizard's mirrored or not mirrored position to be as if I never stepped closer to the enemy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Usually mechanics like this are done with instance variables and timers. Say, the enemy may have State and Direction instance variables.

    When it sees the player - set State to "attack", stop Bullet etc.

    When the player is no longer in LOS - set State to "patrolling". Depending on the Direction variable set mirrored/not mirrored, re-enable bullet.

    On collision with walls - change Direction value, start a timer to resume movement.

    And don't use "Wait" action, because you can't control it. If the player appears in enemy's LOS during the 2s delay, you won't be able to cancel waiting actions. So always use the Timer behavior to schedule events.

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