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.
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.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
5 People are following this question.
How can I zoom out properly within a EditorWindow
Help me please
Problem with "zooming" and rotating
Need to limit zoom in/out of camera script
zoom out in the animator window