Look at Object

Hey Guys,

Just wondering if any of you clever people knew where I would begin with this one!

I want my player to interact with items and doors which I can do, but I want it only to happen when I am looking at it. You know what I mean? Where do I start?

Thanks

You should look into raycasting http://unity3d.com/support/documentation/ScriptReference/Collider.Raycast.html

If you use the default “First Person Controller” or a camera tagged “MainCamera” there is the possibility to automatically limit the raycasting on one axis, in your case the z one, making the door open only when you’re close enough and looking at it.