line of sight trigger for timer not working as intended? (SOLVED)

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • So I have a flying enemy that moves with the line-of-sight and move-to function, and that works fine but i wanted to have the enemy reset its position after not seeing the player for a set amount of time.

    I figured using the timer behavior would do the job but the timer only runs when the enemy has line of sight despite my events stating the timer should run without line of sight (or at least thats what I think I put-I've been wrong before)

    this is all the code here, I try to isolate things into mini-projects to make it easier to see what I've done wrong or if anything random is effecting the code but it just runs the timer while line of sight is activated.

    I attempted tying the timer to a Boolean but that didn't work in a different way- the timer never runs it just exists.

    https://drive.google.com/file/d/1JVNV0bTQjDkjHrBHrvcEyQI455VxFlG2/view?usp=sharing

  • If you look in the inspector, you'll notice that FLYINGENEMY's timer never gets above zero - that's because you're triggering every tick if there's no line of sight so it just keeps resetting. An easy way to fix is by adding a "Trigger once while true" condition to the NOT LOS condition.

  • Thank you! I keep forgetting about the trigger once action and I really need to utilize it more. I added that to both the timer and to the inverted line of sight event and it works as intended now!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Be careful with trigger once because it has a tendency to f things up as soon as there's multiple instances.

    Your current solution isn't far off though, all you have to do is to invert your logic.

    Enemy has LOS -> Start timer lost

    (no need to stop the timer on LOS lost or anything)

    As long as the enemy has LOS, the timer will run indefinitely. When the enemy has lost the LOS, the timer will run out after 1 second and the enemy will move to the return point.

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