2
\$\begingroup\$

In effort to build a racing simulator, I have been working on a working model for the pistons in the engine, and have come to a bit of a stand still.

I have gone through extensive testing, through which we have "dumbed down" our prototype, in efforts to localise the actual problem.

We have a wheel, represented by a basic cylinder. I have added a second cylinder as a sort of knob, which allows us to run the system, and easily visualise its spin, using the following line;

Throughout various tests, a common observation is that the wheel does not appear to spin correctly. Using a collision plane to derive rotations per minute, we have determined that at a certain "thrust", the wheel reaches its maximum speed. Past a value of approximately 'thrust = 5,000', the wheel will not increase its speed. At present, this gives us a rotation of approximately 60 rotations per minute. Ideally, we want to be able to reach the breaking point of about 10,0000.

 rigidbody.AddTorque(transform.up * Time.deltaTime 
                                  * rotatioonSpeed, ForceMode.Acceleration);

What causes the rigidbody to 'cap' its force? Everything is at default, as per various tutorials we have explored; As far as we have looked, various values might have an impact, but not to the point where speed hits a maximum on its own merit.

Incase it matters, a some extra information about the system:

  • We are not yet using conventional Unity measurements. While to scale, the pistons are quite larger then normal, with the cylinder housing the piston holding a length of approximately 2 meters.
  • Once "thrust" exceeds the maximum allowance to impact on speed, the value appears to weigh on breaking force, instead. Prior to reaching maximum speed, the user needs to "push" on the opposite direction, to reverse the rotation. It can take a second or two before the wheel slows down, and reverses its direction. The further past this maximum we go, the quicker the engine will immediately move in the reverse direction.
  • There is nothing else imparted on our model for this behaviour to take place. We are literally dealing with a wheel with a joiner pin on the side.
  • As stated, tutorials we have viewed tend to suggest that the values in the rigidbody should not effect the behaviour, this early. That said, here are our values:

    Mass: 1
    Drag: 0
    Angular Drag: 0.05
    Use Gravity: False
    Is Kinematic: False
    Interpolate: None
    Collision Detection: Discrete
    Constraints: FreezeRotationYZ
    

My best attempts to find a similar problem online ironically reaches a bunch of articles on users attempting to enforce a maximum speed. For best results within scope, we would hope to be able to reach infinite speeds, and separately work out whether the speed of our wheel would cause a major fault, in turn limiting the speed it would potentially reach in practice.

Personally, I suspect that the size of the object would make a difference, as unity perceives it. Another member on my team argues that because the rigidbody uses relative values, size should not make a difference. Unfortunately, this is as far as we can get in localising the problem.

\$\endgroup\$
1
\$\begingroup\$

It looks like it's limited by a single field on Rigidbody. Give this a try:

using UnityEngine;
public class RotateTest : MonoBehaviour
{
    private Rigidbody _rigidbody;

    // Change in acceleration
    public float DeltaAcceleration = 0.1f;

    // To display current angular velocity in editor
    public float Velocity;

    void Start ()
    {
        _rigidbody = GetComponent<Rigidbody>();
        _rigidbody.maxAngularVelocity = float.MaxValue; // <-- most important line
    }

    void Update ()
    {
        DeltaAcceleration += Time.deltaTime*0.1f; // increase acceleration over time
        _rigidbody.AddTorque(Vector3.up*DeltaAcceleration, ForceMode.Acceleration);
        Velocity = _rigidbody.angularVelocity.magnitude;
    }
}
\$\endgroup\$
  • \$\begingroup\$ Interestingly, at 1/10th the speed of light my cube seems to be rotating very slowly. \$\endgroup\$ – jzx Mar 6 '16 at 14:23
  • \$\begingroup\$ This is definently not something we had initially accounted for. I will report back once I am able to add the code and test for a change. \$\endgroup\$ – Gnemlock Mar 8 '16 at 5:11
  • 1
    \$\begingroup\$ This was definitely it. The help file even lists the default as 7, and recommends raising it to accommodate for the speed expected of objects such as car wheels, which is a close approximation of the speeds I am aiming for. Cheers =) \$\endgroup\$ – Gnemlock Mar 8 '16 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.