How can I fix this?

0 favourites
  • 4 posts
  • I put the line of sight behavior on the enemy but it doesn't attack me

    giphy.com/gifs/AjS6kdq1KjI6HoDQL2

    THE ENEMY IGNORES THE EVENT I DID

    ADD ATTACK ANIMATION

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are many issues in your events:

    1-The trigger "On any animation finishes" will never trigger as you stop it manually. That trigger is meant for when the animation reaches the end of the animation.

    2-Your Animation (Attack & Walk) are conflicting because both are constantly true when the enemy is at (less than 85px) distance from P1:

    Example:

    Line of sight = True ----> Set to walk

    The enemy's distance to the player is <85 -----> set to attack, as you never stop the line of sight

    The best way to control the states is by variables.

    Here is one possible solution:

    Add an instance variable to the Enemy and call it "State", and set its (type = String)

    Events:

    -Enemy has LOS to P1

    -Enemy distance to player > 85

    -->Action:

    MoveTo move to player

    Set Mirrored

    Set animation to walk

    Set state to "walk"

    ============================================================

    New event:

    State is = "Walk"

    Distance to player is (=< 85) less or equal 85

    --Action:

    Stop MoveTo

    Stop Animation

    Set State to "Attack"

    Wait 0.2 seconds

    Set Animation to "Attack"

  • When the distance between the player and enemy is low less than 85, the enemy still has line of sight of the player so the first event will keep running. Maybe use a variable on the enemy to distinguish between walk and attack.

  • Also, when you compare enemy.x or distance() to the enemy using System expressions, they will only check the first enemy instance. If you have multiple enemies on the layout, these events will not work correctly. You need to pick an enemy instance first, or use "For Each" loop.

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