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
1
Question by DarkTearStudios · Aug 05, 2021 at 05:56 AM · charactercontrollerrotate

Character making an unneeded rotation when first rotating camera around before moving

EDIT: Updated script and description for readability and to make more sense. I'm using Cinemachine for camera, and rewired for input (it does the same with unity's input, so rewired shouldn't matter but mentioning just in case it does). everything works well, my issue is there is a visual bug that for example when you move the character towards you facing the camera, then move the camera around to the back of the player and try to move forward to where the camera is pointing, the players rotation snaps towards you then smoothly rotates a 180 and starts moving forward, instead of just moving forward. only happens if you mess with the camera after moving the player direction.

Anyone know what the issue might be? I've been looking around here and the googles and messed with cinemachine all day.

heres my move and rotate script:

 public GameObject Player;
 CharacterController charControler;
 public Vector3 moveDirection;
 public Camera camView;
 public float moveSpeed;
 public float gravityScale;
 public float rotateSpeed;
 
 moveDirection.y += Physics.gravity.y * Time.deltaTime * gravityScale;charControler.Move(moveDirection * Time.deltaTime);
 
 float yStore = moveDirection.y;
 moveDirection = (transform.forward* playerInput.GetAxisRaw("MoveY")) (transform.right* playerInput.GetAxisRaw("MoveX"));
 moveDirection = moveDirection* moveSpeed;
 moveDirection.y = yStore;
 
     if (playerInput.GetAxisRaw("MoveX") != 0 || playerInput.GetAxisRaw("MoveY") != 0)
        {
            moving = true;
            transform.rotation = Quaternion.Euler(0f, 
            camView.transform.rotation.eulerAngles.y, 0f);
            Quaternion newRotation = Quaternion.LookRotation(new Vector3(moveDirection.x, 0f, moveDirection.z));
            Player.transform.rotation = Quaternion.Slerp(Player.transform.rotation, newRotation, rotateSpeed* Time.deltaTime);
        }

    

alt text ![alt text][2]

imgonline-com-ua-twotoone-vqsrbp1dd3d.png (247.3 kB)
Comment
Add comment · Show 2
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 DarkTearStudios · Aug 06, 2021 at 02:57 AM 0
Share

Bump, Anyone?

avatar image EricP2265 · Aug 06, 2021 at 08:44 AM 0
Share

I Second this Question. I followed a udemy course that had this exact same script, and its bothering me. Been ignoring it for months so if anyone can help that would be freaking awesome. im not using rewired though

1 Reply

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

Answer by DarkTearStudios · Aug 06, 2021 at 08:43 AM

I fixed it, watched This YouTube tutorial, and changed the entire movement system to that. sucked because I was over 1000 lines into my player controller script and had to change a bunch of stuff to work with the changed values.
Im sure there was a different way that would have saved me that time, but oh well.

Thanks for the help!...

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

143 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

Related Questions

Change gravity point on trigger 0 Answers

RotateAround and Character Controller 1 Answer

How can I stop player snapping back to 0,0,0 rotation when I release keys? 1 Answer

How to rotate the character controller? 1 Answer

Backwards character controller 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