Line Of Sight not recognising obstacles?

0 favourites
  • 9 posts
From the Asset Store
Obstacle Impacts and Cartoon voices, will makes your game more funny!
  • So I have programmed some basic but decent AI that *should* wander around until it has line of sight to the player sprite. It should then chase the player.

    However, although I have set the Wall sprite as an obstacle, the enemy can still see through it and will continuously chase the player, even through mazes. There is probably something obvious I have forgotten to include in the code.

    Screenshots of my issue: Thanks in advance!

    Martin

  • Oops, the imgur link was removed.

    imgur. com/a/Htp5I

  • Have you changed it from solid to custom obstacles in the line of sight behavior properties?

  • Have you changed it from solid to custom obstacles in the line of sight behavior properties?

    Yes, I just checked and it's set to custom obstacles.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think maybe the Chasers aren't being reset when their alertcooldown reaches 0. In event 5 you have a trigger once that won't work well with multiple objects. Say you have two chasers with alertcooldown > 0. When one of them reaches 0 then event 5 runs and sets alerted to false. When the second chaser reaches 0 that event won't run again, it already "triggered once" so the second chaser doesn't get reset.

    Events 5 and 10 do the same thing right? I'd say try getting rid of event 5 and remove the trigger once from event 10 and see if that helps.

  • I think maybe the Chasers aren't being reset when their alertcooldown reaches 0. In event 5 you have a trigger once that won't work well with multiple objects. Say you have two chasers with alertcooldown > 0. When one of them reaches 0 then event 5 runs and sets alerted to false. When the second chaser reaches 0 that event won't run again, it already "triggered once" so the second chaser doesn't get reset.

    Events 5 and 10 do the same thing right? I'd say try getting rid of event 5 and remove the trigger once from event 10 and see if that helps.

    Nothing changed - the Chaser still tracks me through the walls.

  • Bump

  • Can only guess. Can you post a capx?

  • FIXED - eventually by using debug I found that the alertcountdown counted past zero and into the negatives, which set alerted to true. I fixed that by setting it so that if alertcooldown is =<0, it sets alerted to false and alertcooldown to 0, and the Chaser now wanders correctly. Then, when the player was spotted, the Chaser would just infinitely walk in one direction. This was a result of trying to find a path every tick - slowing it to every 0.1 seconds did the trick, and the AI now functions correctly.

    Thanks ramones for the advice!

    -Martin

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