I have my camera rotating with a capsule collision and detect me when it saw me. However, I want this “capsule collision” to be block once the character is hiding behind a wall.
I’ve made the to "BlockAll"collision preset but it didn’t change anything. If someone have the answer, thank you !
You should have the camera fire off a ray trace when it detects the player. If the trace reaches the player the camera can see them but if it doesn’t then an object is blocking its line of sight.
what your trying to do is impossible, it would require you to change the basic shape of the collision. there is however a way to accomplish what your looking to do but with another method. now im assuming you want when the camera sees the player then it does something right? if thats the case you just need to add another check in to see if the player is visible via a line trace.
ok so in the example below we first need to detect if there is a overlap of the sight volume (on begin overlap), then we need to see if it was the player character that overlapped (get player character → equal → branch), next we need to determine if there is anything in between the camera and the player (line trace from camera to player location), then if theres no hit we know there was nothing between the camera and the player (return value, branch).
this entire script basically asks two questions: is the player in range? and is there anything between me and the player?
Got the screenshots in before me.
Another thing to consider may be taking the hit location from the sweep so you can aim your trace at the correct bit of the body.
Last problem is still if the camera detect me and follow me behind a wall i’m still “detected” because I never declenched the “OnEndOverlap” since the camera always look at me.
Is there a solution like don’t use the capsule collision but only the raycast ? it would be simpler maybe with “CapsuleByChannel” thing ?
its difficult to understand what your trying to say. the last branch should be false if there was nothing between the camera and the player. the return value bool basically tells you if there was a hit between the start and end points, or put another way was there something between the two.
yea you could totally do a trace on a timer to confirm if the player is still detected. i wasnt sure on the complete context so i just focused on the main issue of the question which was eliminating detection when behind a wall.