Line Of Sight not recognising obstacles?

Get help using Construct 2

Post » Fri Jan 22, 2016 5:55 pm

Message: Superepicking is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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
B
5
Posts: 10
Reputation: 241

Post » Fri Jan 22, 2016 5:57 pm

Oops, the imgur link was removed.
imgur. com/a/Htp5I
B
5
Posts: 10
Reputation: 241

Post » Fri Jan 22, 2016 9:23 pm

Have you changed it from solid to custom obstacles in the line of sight behavior properties?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Jan 23, 2016 11:00 am

ramones wrote: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.
B
5
Posts: 10
Reputation: 241

Post » Sat Jan 23, 2016 1:59 pm

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.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Jan 23, 2016 4:48 pm

ramones wrote: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.
B
5
Posts: 10
Reputation: 241

Post » Wed Jan 27, 2016 6:48 pm

Bump
B
5
Posts: 10
Reputation: 241

Post » Wed Jan 27, 2016 9:14 pm

Can only guess. Can you post a capx?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Jan 28, 2016 6:32 pm

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
B
5
Posts: 10
Reputation: 241


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, ChesVCF, gamecorpstudio and 20 guests