Hi guys, I ´m making a similar Slender gameplay for a level in my game. I set for my Slender a TP and an orientation in front of my player. I want to set this: when my player see him too long in eyes, screen and controls get lock then the IA slide on the player with a scream and kill the player. I try a lot of thing but nothing work…
Anyone got an idea?
Sry for my bad english
You can just make a raycast between the Slender and the player (you should choose what part of the body seems important to be viewable by the Slender - the head ? the center of the chest ?) each frame and update a timer. When the timer has reached the duration you want, then you kill the player. If the raycast fail, then, reset the timer.
Oh thanks i ´ll try Do you think i need to make a branch between the tp and the raycast? And how can i set the lenght of the raycast?
A branch ?
Use LineTraceByChannel for your raycast so you do not have to care about the length, just the start and the end. Here are more detailed informations about how to use it.
Hi I try to set the raycast but it failed, can you explain me where I’m wrong pls?
The first thing that come to mind is that your “Follow Camera” variable does not exist in your blueprint. You probably copied this one but without create the variable among the variable list of the blueprint.
But I see that you are using the PawnSensing.
In that case, you can just set a timer that you start once on OnSeePawn and reset to 0 if the time between 2 calls to OnSeePawn is greater that the PawnSensing check interval (meaning that the other pawn - the player - has been lost of sight). And if your timer reach the limit, the player is killed.
If your PawnSensing interval is at 0 (meaning you are checking every frame), you can simplify this logic by just checking if the player is still in sight each frame during X seconds.
Hi I set the followed camera, and the ray cast work with a radius!
But, the check get every second, and when the player left vision, the AI does not move anymore… Any idea?
(Mais je crois avoir vu sur ton profile que tu es français, ça sera surement plus simple)
Sorry, I completed forgot to answer ><"
Looking at the calculus of the Line End, it is quite odd.
It seems that your End is the (PlayerCamera + forward * 5000) but since you want the check to be done from the Slender and not the player, you should use GetActorLocation() instead of GetPlayerCameraManager(0)->GetWorldLocation().
Is it the expected behavior ?
Besides, I believe the PlayerCameraManager may not be always at the camera location. Use GetPlayerCameraManager(0)->GetCameraLocation() instead for futures operations.
PS : Although I am also French, it is better to continue in English, as someone else may help you or is trying to achieve the same thing and might find answer here.
Well, my long answer have been completely cut out after I refreshed the page and I cannot edit it…
So, in short, your calculus for the End of the Line trace seems a little weird. You are telling : “give me the position of the PlayerCamera + forward * 5000”, but I believe you want to check if the Slender is watching the player, not the opposite.
Also, you do not need a line trace here since you are using the OnSeePawn and at this time, you already know that your player is being seen (after checking that the seen Pawn is the player).
For future operations with the camera transform, you should use PlayerCameraManager(0)->GetCameraLocation instead of GetWorldLocation because your PlayerCameraManager might not been following the camera (not sure, but I believe).
Finally, although I am French, it is better to continue in English since someone else can take the current conversation and help you, or for another one that look for an answer on this same issue.