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 phxvyper · Jul 19, 2013 at 02:45 AM · cameramovementdelaysmoothingreaction

Camera Movement Smoothing

Given a camera that is looking at an object... This object can turn left or right, and when it does, i want to have a smoothed delay given when the camera reacts.

e.g. When the object moves, the camera should slowly begin to follow then speed up. However, the camera should lag behind slightly. When the object stops moving, the camera should be able to catch up with it but must slow to a stop when it gets close enough. (Essentially the action that takes place with animation smoothing in some animation programs.)

How would i implement this?

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 RyanZimmerman87 · Jul 19, 2013 at 03:35 AM

I don't know if I'm fully qualified to answer this because I myself often think about even better solutions for my current projects camera system.

So I'm going to assume that the camera should always have a certain relative position to your main character or object.

If that's the case you can create an Empty Game Object and position it as a child of your main object and position it to where the camera should be when it comes to a rest. You will use this Empty Game Object as a Transform.position or Vector3 in your script that moves your camera.

So essentially you will use this Empty Game Object Position to determine where the camera should end up (you must update it every time the character/object moves). And then you use that position to move the Camera from it's current location to the destination point using the best math you can come up with.

You will most likely want to keep the Camera's view (LookAt()) locked onto the object. And you will track a start position (camera's current position) and end position (Empty Game Object that's child of main object).

You must also retrieve the time when the camera's movement begins and the total distance to be traveled. Using these two transform points, the total distance to be traveled, and the time your movement started you can calculate the distance traveled which is a percentage (distance traveled/total Distance to be traveled) relative to the time elapsed.

Combining all of this with Vector3.lerp for the movement and Quaternion.slerp for the rotation you can achieve some pretty smooth and natural camera rotations and movements.

Hopefully that helps, I could post the actual code but I'm hoping if you get it working you can post yours if my ideas help you. Or maybe someone who really knows their stuff can come and give an even better answer.

I will be bookmarking this page to see if someone can come up with something better or specific code to compare with mine.

The advantage of this kind of system is that really any kind of control scheme should work the same since the whole system is based on the camera's end position which is relative to the main object. And then it's all about moving the camera as smoothly as possible with the Lerp and Slerps.

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 phxvyper · Jul 19, 2013 at 03:43 AM 0
Share

I found another answer that uses pretty much the same method as yours. I actually had the same idea about making a child empty object for the camera's position. Thank you for your answer :D (Since your answer is essentially the same as the one i found, it'll be the accepted answer)

avatar image RyanZimmerman87 · Jul 19, 2013 at 03:56 AM 0
Share

Awesome if you come up with something really slick and don't $$anonymous$$d posting it I'm sure it would help a lot of people. And I am curious about other peoples details for the math and how it compares to $$anonymous$$e.

Always room for improvement :)

avatar image phxvyper · Jul 19, 2013 at 04:02 AM 0
Share

Agreed! I posted another question based on this one, the code i used has some error occurring. Check it out, perhaps you know what i did wrong! http://answers.unity3d.com/questions/496031/movement-smoothing-script-not-working.html

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

16 People are following this question.

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

Related Questions

how do you add camera lag or delay for flight sim 1 Answer

Movement Smoothing Script not Working 2 Answers

First person camera restriction. 1 Answer

How to use Android Accelerometer(Left and right tilt) to turn a sphere object and camera in that direction? 1 Answer

Moving forward in 3D 1 Answer


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