• 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 1234filip · Jun 20, 2017 at 09:19 AM · rotationcamera rotaterotate objectjitterjittering

Jittering effect when moving character and camera

Hey!
I want to make a game and I wrote some code that really suits my needs but I'm having a problem. When I'm moving the character and the camera at the same time I get t$$anonymous$$s really weird jitter effect. When I'm moving only the camera or the character I don't get t$$anonymous$$s. Here is my code for the camera:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class MouseLook : MonoBehaviour
 {
 
     public float speedH = 2.0f;
     public float speedV = 2.0f;
 
     private float yaw = 0.0f;
     private float pitch = 0.0f;
 
     public Transform tran;
     //T$$anonymous$$s tran is the character transform
 
 
     // Use t$$anonymous$$s for initialization
     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         yaw += speedH * Input.GetAxis("Mouse X");
         pitch -= speedV * Input.GetAxis("Mouse Y");
 
         transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
         tran.rotation = Quaternion.Euler(0, yaw, 0);
 
     }
 }
 

And t$$anonymous$$s is the character code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerMove : MonoBehaviour {
 
         public float speed;
 
         private Rigidbody rb;
         private Transform tr;
 
         void Start()
         {
             rb = GetComponent<Rigidbody>();
             tr = GetComponent<Transform>();
         }
 
         void FixedUpdate()
         {
             float moveHorizontal = Input.GetAxis("Horizontal");
             float moveVertical = Input.GetAxis("Vertical");
 
         rb.MovePosition(tr.position + (tr.right * moveHorizontal * (speed * 0.01f) + (tr.forward * moveVertical * (speed * 0.01f))));
 
     }
 }
 

So I tried a lot of stuff but not$$anonymous$$ng works. How do I make t$$anonymous$$s work without jittering? EDIT: Here is the gif of the jittering. Look at the cube. You don't see it when the gif is small. Just zoom in the page. http://imgur.com/6yChVjI

Comment
Add comment · Show 4
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 SohailBukhari · Jun 20, 2017 at 09:38 AM 0
Share
avatar image 1234filip SohailBukhari · Jun 20, 2017 at 09:47 AM 0
Share
avatar image SohailBukhari SohailBukhari · Jun 20, 2017 at 10:14 AM 0
Share
avatar image 1234filip SohailBukhari · Jun 20, 2017 at 10:59 AM 0
Share

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by 1234filip · Jun 20, 2017 at 04:55 PM

I found a solution. Instead of rotating the camera on the y axis and then rotating the character, I rotated the character directly on the y axis and camera on the x axis. Of course the camera must be a c$$anonymous$$ld of the character.

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

Answer by GilbertoBitt · Jun 20, 2017 at 05:41 PM

for what i see i'm pretty sure that u r setting the rotation, location of the camera directly on it! u should use some sort of lerp to smooth the movement of the camera to where player is, or to the specific rotation that u desire and t$$anonymous$$s will create a smooth transition and remove the jittering.

here some link that can help u!

Lerp Like A PRO

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 1234filip · Jun 20, 2017 at 05:58 PM 0
Share
avatar image 1234filip · Jun 20, 2017 at 06:13 PM 0
Share
avatar image 1234filip · Jun 21, 2017 at 09:00 AM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

86 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

Related Questions

FPS camera jittering when controlled by parent 1 Answer

Set rotation is jittering back to original rotation 2 Answers

How to account for situation using RotateAround 0 Answers

fixed rotation around object 1 Answer

rotate position change????? 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