#How can I detect if a player is looking at something?
1 messages · Page 1 of 1 (latest)
Looking directly at something or in the direction
In the direction
Use Vector3 Dot
Put in the Vector3 of the object - head position in Lhs, and your head forward vector in Rhs, the float output will be -1 to 1 and the closer it is to I think 1 the closer you are to looking at the object
You test if it’s greater than a number depending on how sensitive you want it to be
So when I look at the object the result is around 2.5
Can you send a picture if possible I wanna see your setup
It’s good quality can you look more left though I want to see the circuits for the Lhs
Yeah you gotta make it object position - head position = Lhs
What do you mean by this
Object Position - Head Position = Vector3
@lost urchin Hes saying this:
- Get a
SubtractChip - Wire the
Get Positionof you’re object to the top port of theSubtract - Wire the
Head Positionof the player to the bottomSubtractChip Port.
Tbh the way he told you to do this whole system I would not recommend, also idk why ppl on these channels don’t explain how to do stuff understandingly💀
Thanks
You’re welcome🤙
How would you recommend it, I actually wanna know because I’m not extremely knowledgeable with this kind of stuff
@round cliff @slender plume @lost urchin
Just a note for the most accurate method:
- Dont use head position, use
Get Local Camera Position, which is the actual position of the players camera - Dont use head forward, use
Get Local Camera Forward
lhs/rhs in this case doesnt matter, what does matter is the subtraction order
Object Position - Get Local Camera Position = The direction from the players camera to the object, with a magnitude of the distance
Use Vector3 Normalize to set the magnitude of this vector to 1
Now, using Vector3 Dot, dot this normalized vector you just created by Get Local Camera Forward. This will return a number where -1 is looking directly away, 0 is directly perpendicular, and 1 is directly at. Use the chip Acos to turn this [-1,1] range into a [180,0] angle. This angle will be much easier to work with, now you can just use Less Than on the angle to see if the look angle is less than X degrees
Alternatively, you could check if the dot product result is greater than Cos(Angle), which is essentially the same thing
Is it Get Local Camera Position - Object Position? I thought itd be the other way around
A - B = B to A, you want the direction from Camera to Object, not Object to Camera
oh wait
i said object to camera
i literally double checked lmao
fixed
Oh ok 👌
always triple check
Just mark as answered so other people can see it
Alright
I didn’t tell the guy how to make the system I just restated how the other dude told him how to
which didn't include normalizing, so I fixed it
Alr but u included me in the “normalizing”
Hey I was gonna include that but I didn’t get a response so I didn’t get to that part
That’s just a Cryptic thing lol