I can see you!

Blitz3D Forums/Blitz3D Beginners Area/I can see you!

Pete Carter(Posted 2006) [#1]


what the best way to make the player see A but not B?


jhocking(Posted 2006) [#2]
I'm not sure what you mean. Do you mean like, the camera is at that angle but the occluded character isn't rendered?


Pete Carter(Posted 2006) [#3]
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


puki(Posted 2006) [#4]
You could just make the scenary 'pickable' and use the 'obscurer' value.


puki(Posted 2006) [#5]
There are a few examples in the archives - including this one:

http://www.blitzbasic.com/codearcs/codearcs.php?code=532


Steven Noyce(Posted 2006) [#6]
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!


Pete Carter(Posted 2006) [#7]
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


Sir Gak(Posted 2006) [#8]
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.


GfK(Posted 2006) [#9]
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



Pete Carter(Posted 2006) [#10]
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


jhocking(Posted 2006) [#11]
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.


Red Ocktober(Posted 2006) [#12]
my big question is... those shadows in the pic... real, or faked...

:)

--Mike


puki(Posted 2006) [#13]
We could play 'Spot the light-source'


Pete Carter(Posted 2006) [#14]
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?