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 DoctorSauce · Feb 17, 2014 at 03:11 PM · camera2dfollowshakingdamping

Shaky player effect when I apply a damping camera follow script?

I stumbled across this script on Unity answers, and I decided to stick it on rather than just make the camera a child object of the player. It works perfectly, except when the player is moving it makes the player look like it's shaking. I think the term for that is "clipping" or something like that. Anyway, on the script, when I change the damping variable to 0, the player doesn't shake anymore, so it has to do with the damping. But I want the damping. Is there anyway to have the damping but not have the player appear to be shaking? Here's the script:

 using UnityEngine;
 using System.Collections;
 
 public class CameraFollowFoReal : MonoBehaviour {
     
     public float dampTime = 0.15f;
     private Vector3 velocity = Vector3.zero;
     public Transform target;
     
     // Update is called once per frame
     void Update () 
     {
         if (target)
         {
             Vector3 point = camera.WorldToViewportPoint(target.position);
             Vector3 delta = target.position - camera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 20f)); //(new Vector3(0.5, 0.5, point.z));
             Vector3 destination = transform.position + delta;
             transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
         }
         
     }
 }

Any ideas what's wrong with it? I think from reading online it has something to do with clamping, but I can't seem to figure it out. Any help is much appreciated.

Edit: I should probably add, my game is 2D. Here is a screenshot of it so you can visualize what I mean:

alt text

Nothing else shakes when the camera moves, the tree and ground look normal, it's just the player.

screenshot of 2d game.png (111.0 kB)
Comment
Add comment · Show 1
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 Owen-Reynolds · Feb 17, 2014 at 04:49 PM 0
Share

I think it would be legit to put a comment on the original answer. If they're still here, they'll see the Q is "Active" when they log back in.

But, with "For" misspelled in the name, and a dead var -- point -- down below, and not using Time.deltaTime, I'm tempted to say this may never have worked correctly.

And, clipping, used negatively, means something that should be there is "clipped off." Like if your head blinked out whenever you walked in front of the tree. So your problem isn't clipping.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dead Lincs · Feb 17, 2014 at 03:15 PM

If you have Unity 4.3.4f1 or above you can download the new Sample Assets beta test package free from the asset store which contains the new first person player system with advanced head bobbing and tilting and a smooth mouse look script as well as a head pivot and running all built in :D I find it useful the only thing it doesn't do is crouch but you could add that yourself :)

Comment
Add comment · Show 2 · 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 DoctorSauce · Feb 17, 2014 at 03:21 PM 0
Share

This is really useful to know, thank you. But this camera is actually for a 2D game, so the First Person script wouldn't really help in this case :P Thanks anyway though.

avatar image Dead Lincs · Feb 19, 2014 at 11:27 AM 0
Share

It does also contain a 2D platformer with a player too :)

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

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

Related Questions

camera follow problem-unity 4.3 2d 1 Answer

2D Camera Smooth follow, FixedUpdate and LateUpdate odd difference, help needed. 1 Answer

ortographic camera smooth follow with zoom 1 Answer

2d orthographic camera follow 1 Answer

Camera script 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