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 Ablomis · Jul 31, 2014 at 07:37 AM · movementsmoothtransition

Advanced smooth Camera transition

I need to combine Lerp + smooth transition (using DeltaTime) somehow to have a smooth camera transition: If i use Lerp only it transitions smoothly, but: - it takes a lot of time on the final steps (i need to do it faster, since camera controls are blocked while it moving) - if i do angle check (if the angle is small enough) there is a small jump in camera position. (It is small but noticable and it is not nice)

So i want: - transition camera using Lerp for like 80% of the path - transition camera at constant speed for the last 20% of the path How do i get the speed of a Lerp transition in a frame? (So that i can use it as a speed factor for constant rate transition)

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 robertbu · Jul 31, 2014 at 06:13 PM

Instead of using the non-traditional, eased version of Lerp(), use an easing function. If you search for 'easing functions' or 'Unity3d easing functions' you will find many posts. Here is one blog post by WhyDoIDoIt:

http://whydoidoit.com/2012/04/06/unity-curved-path-following-with-easing/

I'm away from my desk, but here is a bit of untested code that moves from point a to point b in a fixed amount of time with easing.

 var moving : boolean = false;
 
 function MoveTo(a : Vector3, b : Vector3, time : float) {
     moving = true;
     var timer : float = 0.0;  
    
     while (timer <= time) {
         var t : float = 1.0 + Mathf.Pow((timer / time - 1.0), 3.0);
         transform.position = Vectore3.Lerp(a, b, t);
         t += Time.deltaTime;
        yield;
     }
     transform.position = b;
     moving = false;
 }

Replace the 3.0 in the Mathf.Pow() with other values to adjust the curve. And there are many other easing functions (the calculation of 't') other than the one I've used here. Using the sine fuction between 0.0 and PI / 2.0 might look nice for what you are doing. And there are more complicated co-routines that allow easing for both starting and stopping. I'm not using 'moving' here, but it gives you a boolean to check to avoid spawning a new coroutine while the current one is executing (and there are other ways of solving this problem).

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Move along grid where facing 1 Answer

Smooth Movement using transform for fixed movement amount? 0 Answers

Smooth movement using Rigidbody2d 3 Answers

3D Tile Lighting 1 Answer

Smooth Camera Movement script with problem. 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