#How can I detect if a player is looking at something?

1 messages · Page 1 of 1 (latest)

lost urchin
#

I've messed around with the Gaze circuits, but nothing seems to work.

round cliff
#

Looking directly at something or in the direction

lost urchin
#

In the direction

round cliff
#

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

lost urchin
#

Wait I'm confused

#

What do I do with the Result?

round cliff
#

You test if it’s greater than a number depending on how sensitive you want it to be

lost urchin
#

So when I look at the object the result is around 2.5

round cliff
#

Can you send a picture if possible I wanna see your setup

lost urchin
#

I dont have much rn but sure

#

Mediocre quality

round cliff
#

It’s good quality can you look more left though I want to see the circuits for the Lhs

lost urchin
#

Its just local player

#

I deleted my old circuits

round cliff
#

Yeah you gotta make it object position - head position = Lhs

lost urchin
round cliff
#

Object Position - Head Position = Vector3

slender plume
#

@lost urchin Hes saying this:

  1. Get a Subtract Chip
  2. Wire the Get Position of you’re object to the top port of the Subtract
  3. Wire the Head Position of the player to the bottom Subtract Chip 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💀

lost urchin
#

Thanks

slender plume
#

You’re welcome🤙

round cliff
jaunty sage
#

@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

round cliff
jaunty sage
#

oh wait

#

i said object to camera

#

i literally double checked lmao

#

fixed

round cliff
#

Oh ok 👌

jaunty sage
#

always triple check

lost urchin
#

Thank you all for the help

#

I’m gonna close this now

#

I got it working

round cliff
#

Just mark as answered so other people can see it

lost urchin
#

Alright

slender plume
jaunty sage
slender plume
#

Alr but u included me in the “normalizing”

round cliff
#

Hey I was gonna include that but I didn’t get a response so I didn’t get to that part

dark otter