• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SirVictory · Nov 12, 2010 at 08:10 AM · camerarotationmovementpositioninterpolation

Interpolating the motion of a camera moving from one node to another

I have written a script that moves the camera from one node to another when the player moves into a trigger. It also rotates the camera based on the rotation of the node. However, the camera doesn't actually "move", rather it teleports to the node.

I was trying to see if anyone could help me with making the camera move gradually from position A to the the position of the node and also interpolate the rotation while moving.

Here is the code I have written: (This script is attached to the trigger itself)

var camera1 : Camera;

var node : Transform; var Interpolation = 2;

function OnTriggerEnter (hit : Collider) {

 //camera1.enabled = false; 
 //camera2.enabled = true; 
 Debug.Log("Camera movement!");
 camera1.transform.rotation = (node.transform.rotation);
 camera1.transform.position = (node.transform.position);

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by alee · Nov 12, 2010 at 02:36 PM

I haven't tried this before, since I've never needed to, but using the Vector3.Lerp() method should do what you need.

So try something like this:

camera1.transform = Vector3.Lerp(initialPosition, endingPosition, time)

Take a look at this link

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

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 to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to make camera move backwards in relation to player (so behind player), regardless of y rotation of player and camera 1 Answer

Movement relative to Camera and XZ Plane 1 Answer

How to move camera up and down 1 Answer

Rotate 3rd person Character according to mouse position 0 Answers

Orient GameObject rotation to rotation of Main Camera 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges