So I was watching gameplay of a Roblox horror game called “Midnight at the Office” by Morbid Games and in 1 part, the player turns around to find the creature behind them and it quickly hides behind the wall.
Video example:
I know it has something to do with Raycasting with the player looking at the AI then making it disappear. Though as a person who has an ok understanding of scripting, I have no idea how I’ll go about this or what resources to use to achieve this. I was wondering if anyone experienced in scripting may be nice enough to share with me threads or anything that can be found useful for this. As I’m working on a horror game, I want the best for it which this here interested me very much.
No, it doesn’t, you can use LookVector for this, like if the player’s lookvector is a range between vector3.new(1,1,1) - vector3.new(2,2,2) then move the monster.
Oh ok, is there anything else that you’d recommend taking a look at to understand this better besides the API? Anything relating around this specific question?
You should probably use Camera:WorldToScreenPoint which can tell whether a certain position is within the player’s screen, however you would still have to use raycasting to make sure that position is not obstructed by a wall. Here’s a link about it: Camera | Roblox Creator Documentation
Well I should know that, I made the game XD, but Mister_Torrada was right, I used Camera:WorldToScreenPoint to know if the player is looking at the monster at any given time.