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 /
avatar image
1
Question by yosheDev · Mar 28, 2020 at 10:14 PM · physicsrigidbodyrigidbody-collision

Rigidbody rotation constantly spins upon collision.

Hey! I've recently started learning Unity and am just now learning about physics and how to code with them in mind.


[Context] I have created a sphere that moves with Add Force. The X and Z axis are frozen but I have the Y axis unfrozen for gameplay purposes. Interpolation is turned to interpolate. The camera rotates around the sphere in third person and the force is added to the sphere using both key inputs and the cameras position relative to the sphere. Ther sphere is on a terrain that has hills. The mass is 1.85 but can be changed if need be.

---

The problem I am facing is that whenever the sphere collides with the terrains hills, the sphere starts to rapidly spin out of control, which makes the camera jitter. I have read online that affecting the ridigbody's mass would lessen the spin or completely fix the issue; however, that has not solved the rapid spin. Here is my code.

 using UnityEngine;
 
 public class cameraController : MonoBehaviour
 {
 
     public GameObject Player;
     public Transform cam, player;
     public float mouseSens;
     public float speed;
     private float mouseY, mouseX;
     private Rigidbody rb;
     private Vector3 rotationVector;
     
 
     void Start()
     {
         rb = Player.GetComponent<Rigidbody>();
         Cursor.lockState = CursorLockMode.Locked;
         Vector3 rotationVector = new Vector3(0, mouseX, 0);
         //offset = (cam.transform.position - target.position).normalized * camDistance;
     }
 
     void FixedUpdate()
     {
         Rotate();
     }
 
     public void Rotate()
     {
 
         mouseX += Input.GetAxis("Mouse X") * speed;
         mouseY += Input.GetAxis("Mouse Y") * speed;
         mouseY = Mathf.Clamp(mouseY, -35, 89);
 
         
         transform.LookAt(cam);
 
         cam.rotation = Quaternion.Euler(mouseX, mouseY, 0);
         Quaternion deltaRotation = Quaternion.Euler(rotationVector * Time.deltaTime);
         rb.MoveRotation(rb.rotation * deltaRotation);
 
     }
 }

Help and insight would be greatly appreciated by this newbie!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by kubajs · Mar 30, 2020 at 10:19 PM

Try to set Rigidbody angular drag to some higher value if this is acceptable.

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
1

Answer by yosheDev · Mar 30, 2020 at 10:16 PM

Update for anyone with a similar problem: Freezing the Y Rotation of the object can fix this problem. Unfortunately, I need the Y Rotation for my game. I am currently investigating ways I could create a rotation while still freezing the Y rotation on my Rigidbody. Once again, open to input and advice.

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 slake_it · Jan 12, 2021 at 04:13 PM

this happened to me with Rigidbody2D, The issue turned out to be my object was rotated 180 degrees around the y-axis but I guess since the physics 2D system knows nothing about rotation around y-axis, that caused weird behavior.

  • if you're having this in 3D rigidbody, then maybe check the scale of your object, check if it's negative

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

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

Related Questions

Rigidbody NavMeshAgent Causing Crazy Collisions with Player. 0 Answers

Knock down moving target ridigbody from collision. 1 Answer

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer

Rigidbody doesn't fall when platform below it shrinks to nothing. 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