- Joined
- Apr 19, 2011
- Messages
- 447
Hi there.
I'm trying to implement in my proyect a custom sight field for the enemies.
Basicly, the enemy will only be able to see your character if he is inside a certain cone of sight before him.
Please, look at the attached picture, I think it's better explained there.
The red dot, in the middle of the circle, it's the enemy.
The blue dot is the character (consider it's position as an arbitrary position).
The enemy will ONLY be able to see and chase the character if he is inside the area covered in green color, with a radius of D.
As you see, this area goes 60 degrees to the right of the enemy's facing, and 60 degrees to the left. It's a 120 degrees sight range.
In order to check if the character is in the desired region, I first checked if the character is inside the circle (radius D). That's the easy part.
The problems started appearing when I try to check if the character is in the green area.
This is what I've done:
I'm not very good with triggers; maybe there's a much more simpler way to do this. Maybe I'm missing something important. Maybe I just went mad with those angles...
Anyway, can someone help me fix this? Thanks in advance.
Regards
I'm trying to implement in my proyect a custom sight field for the enemies.
Basicly, the enemy will only be able to see your character if he is inside a certain cone of sight before him.
Please, look at the attached picture, I think it's better explained there.
The red dot, in the middle of the circle, it's the enemy.
The blue dot is the character (consider it's position as an arbitrary position).
The enemy will ONLY be able to see and chase the character if he is inside the area covered in green color, with a radius of D.
As you see, this area goes 60 degrees to the right of the enemy's facing, and 60 degrees to the left. It's a 120 degrees sight range.
In order to check if the character is in the desired region, I first checked if the character is inside the circle (radius D). That's the easy part.
The problems started appearing when I try to check if the character is in the green area.
This is what I've done:
-
Sight
-
Acontecimientos
- Tiempo - Every 0.50 seconds of game time
-
Condiciones
- (Distance between (Position of Enemy) and (Position of Character)) Menor que o igual a D
-
Acciones
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Si: Condiciones
- ((Angle from (Position of Enemy) to (Position of Character)) Menor que o igual a ((Facing of Enemy) + 60.00)) and ((Angle from (Position of Enemy) to (Position of Character)) Mayor que o igual a ((Facing of Enemy) - 60.00))
- Entonces: Acciones
- Otros: Acciones
-
Si: Condiciones
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Acontecimientos
I'm not very good with triggers; maybe there's a much more simpler way to do this. Maybe I'm missing something important. Maybe I just went mad with those angles...
Anyway, can someone help me fix this? Thanks in advance.
Regards