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 phorne_tca · Jan 02, 2012 at 09:15 AM · cameravectorseasing

Camera rotation ease out

So, I'm basically new to Unity and have been messing with it for the past couple of days. I'm fairly familiar with coding, but am having a little bit of a hard time wrapping my head around how to handle vectors and easing.

I have an object that's the only subject in my scene. I have an empty GameObject (called CameraTGT) that's parented to my subject. I want to be able to rotate the camera around that CameraTGT object when I'm holding down the left mouse button, but when I let go, I want it to follow the direction the mouse was going, but to ease to a smooth stop.

I'm guessing that I would grab my camera's position from the previous frame and my camera position from my current frame and make a vector out of it. If the MouseButton is down, then it doesn't ease at all. If the MouseButton is up though, it should calculate the vector for the current frame, and then each subsequent frame should be multiplied by something like 90%, until it's basically at a stop.

This sounds stupid, but I can't understand how to translate the camera's positions to a Vector that can then be applied repeatedly on future frames so that it slows to a stop...

PS - the object can't rotate, only the camera...

Any suggestions?

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

Answer by Winterblood · Jan 02, 2012 at 01:54 PM

Parent the camera to a dummy object at the target position, and rotate it around the target by rotating that dummy object. Then you only have one float (transform.rotation.eulerAngles.y) to worry about and no loss of precision.

To give the camera some rotational inertia:

  • While the LMB is pressed, store the difference between last frame and this frame (angular velocity).

  • While the LMB is released, add the stored rotational velocity to the current rotation, and reduce the stored vel by 10%.

That's a crude solution. Ideally you'd calculate the rotational velocity properly using Time.deltaTime and decay it properly to ensure it behaves the same at all framerates.

Comment
Add comment · Show 1 · 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 OfficialHermie · Feb 11, 2019 at 07:18 PM 0
Share

@Winterblood Doesn't work for me because I found situations where I moved the mouse quickly to the right, and without noticing it, introduced a tiny movement to the left at the last moment. Stil investigating what works better.

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

6 People are following this question.

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

Related Questions

How to make camera position relative to a specific target. 1 Answer

easing camera rotation after mouse up? 0 Answers

RTS camera movement - easing? 1 Answer

In-game video monitor without render-to-texture 0 Answers

Deploying Unity app to Augmented Reality headset results in a flipped/mirrored view - image attached 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