Hey guys
I was writing a source, but unfortunately I can’t get any logic to write a source to align the camera with the nearest object with a determinated tag, if it is near to the center of the screen.
I try to explain this better:
I have a camera moving and rotating.
I want that if it founds a particular gameobject that is near to the camera and has a particular tag, it will aligned to it, and it remains untill, another gameobject doesn’t take its position or it will destroyed.
How can I explan to Unity?
I tried with Camera.main.ScreenToWorldPoint ();
I cannot find any logic!!!
Please help
Thanks byeeee!
I would try with the default scripts, (import the standard assets scripts package)
then try SmoothLookat.js in the camera…
Assign nearest object as target to that script…
That is oke, but my problem is not to align the camera, but to detect, when align, I mean
if the object has the setted tag (example enemy) then (simple, i can do this)
if the object is the nearest then (simple I can do this)
if the object is near to the center of the screen then (here is the problem)
align the camera to the object.
I don’t know how to detect, if the object is near to the center of the screen. I have tried with
Camera.main.ScreenToWorldPoint()
But I don’t know how to explain to unity!!! What’s the logic?