I can see you!
Blitz3D Forums/Blitz3D Beginners Area/I can see you!
| ||
what the best way to make the player see A but not B? |
| ||
I'm not sure what you mean. Do you mean like, the camera is at that angle but the occluded character isn't rendered? |
| ||
no sorry, what i mean is if A and B are enemy troops and the player is walking along, enemy B should not be able to see the player because there is a box in the way but enemy A has a clear line of sight. how do you check if the enemy troops have anything blocking their line of sight to the player. like in metal gear when snake hides behind a box and the enemy dont see him. Pete |
| ||
You could just make the scenary 'pickable' and use the 'obscurer' value. |
| ||
There are a few examples in the archives - including this one: http://www.blitzbasic.com/codearcs/codearcs.php?code=532 |
| ||
There are three main ways. One is to use LinePick from the enemy to the player and see if the player was picked. Another is to use the EntityVisible command. Another way is to make a pivot that has collisions with the things that will obstruct the enemies veiw and stop as it's reaction. Hide it, then position it at the enemies position, then show it, and position it at the players position. Then check where it is. If it is at the players position, then there is nothing in the way. Otherwise, there is. I hope that helped! |
| ||
fredborg's funtion is very good but i just thought id get everyones view on the best way to do it. now ive just got to figuare out how to change the height of the player enities collision box when he ducks down. thanks for your help everyone Pete |
| ||
Try using this; EntityBox entity,x#,y#,z#,width#,height#,depth# Parameters entity - entity handle# x# - x position of entity's collision box y# - y position of entity's collision box z# - z position of entity's collision box width# - width of entity's collision box height# - height of entity's collision box depth# - depth of entity's collision box Description Sets the dimensions of an entity's collision box. |
| ||
This function simulates a 'line of sight' with whats actually a 140 degree field of view (-70/+70). Any entities that an object can hide behind will need to have their 'obscurer' flag set with EntityPickMode before EntityVisible will work correctly.Function CanSeeEntity(EntityA,EntityB) Local FOV = 70 Local Result = False If Abs(DeltaYaw(EntityA,EntityB)) < FOV If Abs(DeltaPitch(EntityA,EntityB)) < FOV If EntityVisible(EntityA,EntityB)) DebugLog "I can see you, Kirk. Can you see me?" Result = True EndIf EndIf EndIf Return Result End Function |
| ||
thanks ill give both a go. im going to have upto 4 enemy soldiers walking round any one scene is this going to give me a big performance hit using if the 4 npcs are checking for fov all the time. Pete |
| ||
4 shouldn't be a big problem, but if you want to be safe then don't have them all checking every frame. They shouldn't have lightning fast reaction time anyway, so staggering the checks over separate frames is no big deal. |
| ||
my big question is... those shadows in the pic... real, or faked... :) --Mike |
| ||
We could play 'Spot the light-source' |
| ||
the pic was just to give an idea of what i want to talk about with out letting on what my game is about. i just did that quickly in 3d world studio. so yes its not a game and im not sure why i lightmapped the scene? |