Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Alayna · Jan 14, 2013 at 03:39 PM · cameramovementlerpsmooth

Move A Camera Between Two Points Smoothly

Hello everyone, Im trying to move make a transition between a far away camera and a closeup one. They both can move around and be in random places when the player chooses to switch between them. I've tried making it so that there is a third camera that is turned on during this transition and it moves between the two points where the other cameras are smoothly, then changes to the other camera.

Currently it only instantaneously jumps between locations, and I dont know if this will translate the rotation smoothly as well since it is only Vector3? Here is the script just dealing with the transitional camera that I have so far.

 var posCam1 : Transform;
 var posCam2 : Transform;
  
 var positionCurrent : Transform;
 
 var transitionCamera : GameObject;
 
 var speedAdjust : float;
 
 function Start(){
     ReOrient();
 }
 
 function ReOrient (){
         positionCurrent.transform.position = Vector3.Lerp(posCam1.transform.position, posCam2.transform.position, Time.deltaTime * speedAdjust);
         transitionCamera.transform.position = positionCurrent.transform.position;
 }

Would someone be willing to explain to me what I am doing wrong? Thanks!

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
0
Best Answer

Answer by TheHoboCoder · Jan 14, 2013 at 03:56 PM

Try calling reorient from Update

Comment
Add comment · Show 3 · 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
avatar image Alayna · Jan 14, 2013 at 04:19 PM 0
Share

Didn't realise it was going to be such a simple solution hah! Thanks! One more question If you wouldn't $$anonymous$$d, how would I make the function be reversible, change it back after I get to cam2's position?

avatar image TheHoboCoder · Jan 14, 2013 at 04:58 PM 0
Share
 function ReOrient (reverse : boolean){
     if(reverse) {
         positionCurrent.transform.position = Vector3.Lerp(posCam1.transform.position, posCam2.transform.position, Time.deltaTime * speedAdjust);
     }
     
     else {
         positionCurrent.transform.position = Vector3.Lerp(posCam2.transform.position, posCam1.transform.position, Time.deltaTime * speedAdjust);
     }
     
     transitionCamera.transform.position = positionCurrent.transform.position;
 }


So if you want to reverse it, just call:

 function Update () {
     ReOrient(true);
 }


For normal behavior call:

 function Update () {
     ReOrient(false);
 }
avatar image Alayna · Jan 14, 2013 at 05:56 PM 0
Share

For some reason it only works in forward but not in reverse, I think it may be because of this weird thing thats happening with cam1. When I play forward, the transitional camera moves along the correct path, but for some reason I cant figure out, cam1 follows the transitional camera.

They aren't parented, and I have no other scripts than this acting on the cameras. When I try the reverse of this function, it goes to the starting location, but because cam1 follows it, it has nowhere to transition to, so it just stops.

Do you know what could be causing this?

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.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Problems with Lerp. 1 Answer

How to smooth my camera (Vector3.Lerp) 0 Answers

Smooth Camera/Object Movement 1 Answer

How you change another script value smoothly on trigger 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges