Hello, I have 2 game objects in diffrent positions and I duplucated the first object in the same positions..Now I have three Objects. How can I change the 3.object's position in the direction between the first 2 objects?
I tried to use Vector3.Distance but I couldn't find the way :(
My purpose is to be able to control the camera in horizontal way for zoom..
Answer by DaveA
Feb 29, 2012 at 01:12 AM
'Zoom' is a term used generally with the Camera's FOV (field of view). If I understand you, you want to turn object 3 to LookAt the point between object 1 and object 2, is that correct? If so, add object 1's position to object 2's position and divide by 2. That gives the mid-point on a line between 1 and 2. Then use Transform.LookAt at that point. If you want to transition to that point, use a Slerp function. Examples are in the docs.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
5 People are following this question.
How can i mimic the "Frame Selected [F]" camera move? (Zoom Extents, Zoom to Fit)
How to stretch a GUI texture over it's original size?
Sniper zoom when right click?
How to accurately zoom (not dolly) and pan Camera to mouse click position