Search Unity

Rigidbody2D AngularVelocity is setting its self to zero at low values

Discussion in '2D' started by Runalotski, Jul 1, 2015.

  1. Runalotski

    Runalotski

    Joined:
    Mar 4, 2014
    Posts:
    10
    Hello I have been trying to find out about this but cannot find anything on it.

    The problem when a AddToque() force is around 1% of the mass of the Rigidbody2D the Object will rotate for 20isf frames then is set to 0.

    the Rigidbody has no drag values at all

    the set up work fine if the force is 5% or greater then the mass of the rigidbody

    To re-create
    Attach this script to a Object with RigidBody2D set to 100 mass, with no colliders, no drag and gravity scale to 0

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Test : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start ()
    8.     {
    9.         GetComponent<Rigidbody2D>().AddTorque(1);
    10.  
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update ()
    15.     {
    16.         Debug.Log(GetComponent<Rigidbody2D>().angularVelocity.ToString("F2"));
    17.     }
    18. }
    19.  
    The expected behavoir is that is should keep spinning for ever.

    I was wondering if this is just happening to me, or if its a known behavoiur or a bug.

    Thats all for the problem i am having but for context to why its a specific problem for me read on.

    Why is this an actual problem for me.

    Because its intended to simulate a large capital ship, where the player inputs a request of 20 Degrees of rotation a second and the large ship will slowly increase its Angular velocity unitl it reaches the disired amount but at the moment its in such small increments that i want it keeps getting reset to zero and so never gets above 2 degrees per second.

    But increasing the force to not have this problem means the rotation of the ship is too fast and will destory the gamplay element i wish to create.

    setting the angular velocity manually probably will work but is not as elegant as physics collision could happen at any time and i would like the collision to affects the ship rotation if it does.

    it is probably possible to code an edge case for this but I wanted to see if there is any information from the communnity before i invested the time into it.

    Again this post is to see if anyone else gets this problem, to find out if its unity or my unity specifically and if any knows more why it behaves like this.

    Thanks for any info on this topic.