This a Bug or am I Crazy?

0 favourites
  • 8 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hey there,

    I am controlling enemy movement with Line-of-sight, which works just fine. My issue is, if the Player moves away, I want to be able to delay the Enemy reaction time or even prevent movement until attack animation is finished playing. To add a bit of realism.

    Anyway, I thought I had it all figured out by using a Wait X Seconds event, every time the Player moved away. Unfortunately, this some how disabled my collision checks and now the monster is just walking right on top of the Player. I have attached an image of exactly how I am playing around with. Does anyone see what I am doing wrong here?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The enemy still has line of sight during the wait, so it fires again and again and again, etc.

    Maybe add a check for "Attack Animation not playing," that way that event doesn't even fire if that animation is in progress?

  • The enemy will have line of sight, yes, but it will not have been told to set its angle or to move forward for at least one second. It also doesn't explain why collision checks are now ignored.

  • Try fixing the first issue, then see if it still happens. As Paradox says, you are queuing up at least 60 wait/moves in that one second.

  • Condition: Enemy Has lineofsight to player | Action: System: Wait 1.0 seconds

    Action: Enemy: Sent Angle Toward (player.x,player.y)

    Action: Enemy: Move forward 1 pixels

    Sub-Event

    Condition: Enemy: is overlapping player at offset (15,0) | Action: Enemy: Set line of sight range to 0

    Else

    Condition: Enemy: is overlapping player at offset (-15,0) | Action: Enemy: Set line of sight range to 0

    Else

    Condition: Enemy: is overlapping player at offset (0,15) | Action: Enemy: Set line of sight range to 0

    Else

    Condition: Enemy: is overlapping player at offset (0,-15) | Action: Enemy: Set line of sight range to 0

    Else

    Condition: Enemy: is not overlapping player | Action: Enemy: Set line of sight range to 10000

  • Solution of tomsstudio seems clever. It propably works.

    Personally, I think the way "wait" action works makes it quite problematic to use if you don't exactly know how it works. I prefer making my own timers using instance variables like this:

    • Make instance variable ReactionTime for Enemy.
    • Condition: Every 0.1 seconds | Action: Enemy: Add 0.1 to ReactionTime.
    • Replace all "set line of sight range to 0" actions with Action: Enemy: Set ReactionTime to 0.
    • Add another condition to your first event: Enemy: ReactionTime > 1.0.
    • Remove your last event (it is now useless).
    • Remove wait action.

    I feel that in many cases variable based timers give better control over events than wait action or timer behavior.

  • I should have made my answer clearer. The wait is the problem, that event will fire every tick for that first second it's waiting.

    So when the first of those seconds is up all those waits that build up will fire each following tick (the end of each of those wait periods) moving your enemy 60 or so pixels. (nothing you can do about the movement, as it all happened 60 ticks ago.)

    You could also put an instance variable on the enemy, "TargetSpotted" that you set when the wait event is first fired, so that it doesn't repeat.

    Add a condition to event 1: TargetSpotted=0

    and an action to event 1 before the wait: Set TargetSpotted to 1

    and an action to event 1 after the wait: Set TargetSpotted to 0

  • What a weird way to program the Wait function. That explains everything and now I can fix my issue. That's actually a fix for some of my other games as well lol

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