- Home /
Camera Lookat Cursor Tutorial?
Hi! Is there a thing like transform.lookat
But it looks at the cursor?
I added "tutorial" Because if there's a tutorial, I am more visual, but I will read through docs if I must.
Can you explain what do you mean by camera looking at the cursor?
For example if we take a birds-eye view on a game (say something like a strategy game) and you want camera to look at the place where the cursor is hovering (like a building or terrain) you could make a RayCast from the camera that goes through the cursor and then when that RayCast hits something (building, terrain etc.) make camera LookAt the position of the RayCast's hit position.
Other than that you will have to analyze your question more.
Answer by tusadi · Dec 26, 2016 at 02:29 PM
This was the first thing that came up on google
Answer by UnityCoach · Dec 25, 2016 at 07:17 PM
There's probably a tutorial somewhere that shows how to do just that, but it's easier to tell you how than finding a good free tutorial.
First, you need to cast a ray using Physics.RayCast() and the pointer location, using MousePosition like described here
Then you can use the position you get as the Look At position. See here
Hope this helps.