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 /
This question was closed Apr 30, 2020 at 08:11 PM by FluffBear55 for the following reason:

I've solved the problem on my own after a few days of troubleshooting.

avatar image
0
Question by FluffBear55 · Apr 29, 2020 at 07:43 PM · camerafpstps

Third Person Camera Controller Jitter

Hello! I have this problem with my camera. Whenever the camera is looking up and the character walks up a slope, the camera jitters.

I'm pretty sure I narrowed the problem down to the collider.

Heres the code for the Collider:

 public float minDistance = 1.0f;
 public float maxDistance = 5.0f;
 public float smooth;
 public float distance;

 Vector3 dollyDir;

 public GameObject cameraBase;
 public FPCamController fpCamController;

 // Use this for initialization
 void Start() {

     distance = transform.localPosition.magnitude;
 }

 // Update is called once per frame
 void Update() {
     dollyDir = transform.localPosition.normalized;

     Vector3 desiredCameraPos = transform.parent.TransformPoint(dollyDir * maxDistance);
     RaycastHit hit;

     if (Physics.Linecast(cameraBase.transform.position, desiredCameraPos, out hit)) {
         distance = Mathf.Clamp(hit.distance * 0.87f, minDistance, maxDistance);

     } else {
         distance = maxDistance;
     }

     transform.localPosition = Vector3.Lerp(transform.localPosition, dollyDir * (distance - .25f), Time.deltaTime * smooth);
     print(transform.localPosition);
 }

Here's a video of the problem https://youtu.be/UtemMD-_syA P.S. If some of the code is not the best, forgive me I'm new :)

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

  • Sort: 
avatar image
0

Answer by Glaas · Apr 29, 2020 at 08:57 PM

Hi ! The pinned comment on this video https://www.youtube.com/watch?v=MFQhpwc6cKE should resolve your issue. Indeed, Lerp() is very bad with moving objects. Try using Vector3.SmoothDamp instead.

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 FluffBear55 · Apr 29, 2020 at 10:33 PM 0
Share

Hey there! Thanks for trying to help, but it still doesn't seem to work. I noticed it also happens when the character is sprinting. I've noticed that when the camera jitters it moves towards the $$anonymous$$imum distance I set. I have the $$anonymous$$imum distance set to .75, but if I set the $$anonymous$$imum distance to 0 then the camera moves to the opposite Vector3 and stays there. So if it was at (1, 0, -4.5) it would move to (-1, 0, 4.5). Also, it doesn't jitter at all when the character is sprinting backwards or downwards. When I set the $$anonymous$$imum distance to 0 and it flips it will flip back normally if I move backwards. This is definitely really weird.

Follow this Question

Answers Answers and Comments

227 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 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 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 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 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 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 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 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 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 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 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

FPS Multiplayer setup - TPS models for other clients 1 Answer

Camera smooth transistion 2 Answers

Keyboard / Mouse control for FPS 0 Answers

Movie Textures. 0 Answers

Does anyone know any good 3rd Person Shooter tutorials? 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