Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by subver · Mar 03, 2016 at 03:18 PM · unity5camera-movementsmoothfollow

Another Smooth Camera Follow problem

I know this is asked a lot but I've been through a ton of these threads and still cannot seem to get my camera nice and smooth. I've tried various methods.

As of now here are my codes..

My player movement is as follows (you can only move left and right):

 void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, 0.0f);
         rb.AddForce (movement * speed);
     }

This is my favorite type of camera movement (as far as how I want it to work goes), but is super choppy, mostly when the player is going far right or far left (like holding down left or right so the player is on the edge):

 void LateUpdate () {
         Vector3 velocity = Vector3.zero;
         transform.position = Vector3.SmoothDamp(transform.position, GameObject.Find("Player").transform.position + offset, ref velocity, 0.03f);
         transform.rotation = Quaternion.Euler(0f,0f, (velocity.x/-10));
     }

This one seems to be a bit smoother but is STILL not perfectly smooth (and doesn't have the nice x rotation but I haven't written it yet) - the problem still arises when the player is going hard left/right:

 void LateUpdate () {
         transform.position = Vector3.Lerp(transform.position, GameObject.Find("Player").transform.position + offset, 20f * Time.deltaTime);
     }

My player is set to Interpolate, I tried setting my application to 60fps, I've tried many of the scripts I've found and I just cannot get a perfectly smooth camera. It always gets choppy when the player is moving hard left or right (when the player is on the edge and can no longer move right within the field of view) while the camera follows.

I've put the camera as a child of the player with no script attached and it is perfectly smooth so I don't believe the problem to be the player movement.

Any help would seriously be great! I'm a little frustrated I can't figure this out but it seems other people have their scripts mostly fixed when they put the camera script in LateUpdate.

Thanks so much for reading! I know this is probably annoying to have yet ANOTHER smooth camera follow question so I do apologize for that!

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

Answer by Magius96 · Mar 07, 2016 at 04:19 PM

I would suggest using something like iTween on your camera movements. If used right, it can help smooth the camera movement out.

http://www.itween.pixelplacement.com/index.php

Don't let the "animation" word scare you, because what you are trying to do is in effect animating the camera position.

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 subver · Mar 07, 2016 at 04:30 PM 0
Share

Thank you so much for the reply! I will absolutely try this out! This camera has been bugging me and I just can never seem to get it nice and smooth so I hope this helps. Looks like it could come in handy for a bunch of different things, though!

avatar image subver · Mar 07, 2016 at 04:41 PM 0
Share

So I'm definitely doing something wrong. I have this in my LateUpdate on my camera script: iTween.$$anonymous$$oveBy(cam, iTween.Hash("x", GameObject.Find ("Player").transform.position + offset, "easeType", "easeInOutExpo", "loopType", "pingPong", "delay", .1)); where "cam" is the $$anonymous$$ain Camera, but I am getting an error "Cannot cast from source type to destination type.

I'm a little confused by their sample. Sorry, I am pretty new to C# and Unity so I don't think I fully understand how this iTween works yet.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to make camera follow player from point to point 2 Answers

How do you move the camera with the player. Whats wrong with my code? 0 Answers

Create a smooth camera without jittering/flickering in 2D 3 Answers

Making camera follow and rotate player 0 Answers

C# Smooth Follow Space Ship 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