Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 felixpk · Dec 20, 2013 at 09:09 PM · cameramotionshake

Camera Anti-Shake-System

Hey there, I have a camera atached to my Rig's head bone, as you can imagen the camera moves with every step the player does, I just don't want to unparent the camera from the headbone because I don't want to lose completely the camerashake.

And that is my question: has anybody an idea how to make a camera stabilisation script or something like this?

Thanks in advance!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by robertbu · Dec 20, 2013 at 09:43 PM

Replace your camera with an empty game object at the same position and rotation. Then use RotateTowards() and MoveTowards() to soften your movements. Untested example:

 #pragma strict
 
 public var target : Transform;
 public var moveSpeed = 1.0;
 public var rotateSpeed = 90.0;
 private var myTransform : Transform;
 
 function Start() {
     transform.position = target.position;
     transform.rotation = target.rotation;
     myTransform = transform;
 }
 
 function Update() {
     myTransform.position = Vector3.MoveTowards(myTransform.position, target.position, moveSpeed * Time.deltaTime);
     myTransform.rotation = Quaternion.RotateTowards(myTransform.rotation, target.rotation, rotateSpeed * Time.deltaTime);
 }

Attach this script to the camera, then drag and drop the empty game object on the 'target' variable in the Inspector. You will need adjust 'moveSpeed' and 'rotateSpeed' so that the correct amount of shake comes through.

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 felixpk · Dec 21, 2013 at 12:01 PM 0
Share

Thank you for the answer, but unfortunately this did not work for me. For example when the character begins to run, the camera is behind the character because it speeds up to slowly. But if I increase the speed factor there is no smoothing anymore.

Isn't there a way to detect the movement of the headbone to move the camera to the opposide direction of it?

avatar image robertbu · Dec 21, 2013 at 10:44 PM 0
Share

Isn't there a way to detect the movement of the headbone to move the camera to the opposide direction of it?

That's kinda what this script does, though it uses the whole object, not just the head bone. Without your code to play with and perhaps a video reference about what kind of movement you are looking for, all I can do is guess and give alternate solutions of perhaps ever increasing complexity. The next thing I would try is replacing the $$anonymous$$oveTowards() with Lerp() and the RotateTowards() with Slerp(). The rest of the code can remain the same, but the meaning of 'moveSpeed' and 'rotateSpeed' will change, and therefore you will have to reduce their values.

avatar image adriandevera · Apr 27, 2020 at 09:13 PM 0
Share

Thank you this worked nicely.

avatar image
0

Answer by Renan-Reis · Dec 12, 2021 at 11:47 PM

Check this asset:

Camera Stabilizer

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

20 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 avatar image avatar image avatar image avatar image

Related Questions

camera follow problem-unity 4.3 2d 1 Answer

How can my window shake while im running? 1 Answer

iTween Shake intensity issues 1 Answer

Camera shake scripts works but camera wont stay in prefab 2 Answers

Constant camera shake. 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