How can I change things by looking at them?

I’ve seen some games where you look at an object, then look away, and when the player looks back at it the object changed (like writing on the wall or a different level all together) and I have no idea what that’s called or how to look it up.

I THINK it has something to do with line/ray casting but that changes things while the player is looking at it (like registering what object the player is looking at and making it shoot a laser) which is close but not what I’m looking for.

What is that action even called? What do I need to look up in the Unreal documentation to read up on this?

Thanks in advanced!

I don’t think this effect has a standard name, but you can tell when the player is looking at something ( first person, anyway ), by making a line trace from the camera.

You can also use this to know when they’re looking away.

You can save some performance by using a dot product to check the player might be able to see the object first, then only ray casting to check occlusion if the player is looking in the right direction.

I think I first heard these being called look-at triggers in a GDC by one of Bioshocks developers. The idea is the trigger takes the forward vector of the camera and the direction vector from the camera to the object and computes the dot product. If the dot product returns a value greater than a threshold (say .9 for arguments sake), the object should be relatively close to screen centre and rays can be cast to confirm visibility.

There are a few edge cases that get more challenging, like handing partial occlusions or very large objects, but it doesn’t sound like that’s the use case here.

The rays alone should work, this suggestion is just to help save on having to fire comparatively expensive rays into the scene when they won’t necessarily give you more information.

1 Like

Sorry for taking so long but thank both of you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.