Line of Sight "field of view"

New releases and general discussions.

Post » Sun Feb 08, 2009 5:42 pm

Well, having an field of view for it... so, if an actor is, for example, 300 pixels from the object with the behavior, it can't see the actor, even if he's not behind an obstacle,,,

Well, I can make something like this, using a mask, but well, it's better having it on the behavior don't you think?
B
2
G
4
Posts: 27
Reputation: 1,104

Post » Sun Feb 08, 2009 11:07 pm

instead of using a mask, i believe it is more efficient (and simpler) to just add an extra condition to your LoS-event:
[code:akr5ng2v]+ Sprite has LoS to Target
+ Compare: Distance( Sprite.X, Sprite.Y, Target.X, Target.Y ) Less Than 300
-> ...[/code:akr5ng2v]you could also have the field of view limited by angle, so the actor behaves more 'realistic' (e.g. can't look in the opposite direction he's walking):
[code:akr5ng2v]+ Sprite has LoS to Target
+ Compare: AngleDiff( Sprite.Angle, Angle( Sprite.X, Sprite.Y, Target.X, Target.Y )) Less Than 45
-> ...[/code:akr5ng2v](the last one was actually what i thought you had meant when typing 'field of view')
it's rather easy to do in events when you know how, but i agree that the scenario might be rather common.
B
2
S
2
G
4
Posts: 171
Reputation: 1,792


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 6 guests