Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED]HingeJoint2D.Motor.MotoSpeed, Not Affected By Code?

Discussion in 'Scripting' started by renman3000, Nov 22, 2018.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    SOLVED.
    Add, at end of image code.
    Code (csharp):
    1. hingeJoint2D.motor = motor;

    I have a Unity, HingeJoint2D.motor, as JointMotor2D. In code, I have set the joint to useMotor = true, and set the motorSpeed and maxMotorTorque.

    This should be correct. My bool of useMotor appears as should in the inspector (going from false to true, at Start()). However, neither my motorSpeed, nor maxMotorTorque are altered (according to the inspector), despite the console print, check I have says the values are 200 and 100 respective, the remain 0 and 100000 in the inspector.

    As such, no spin courtesy of the motor occurs via script. If I change the motorSpeed value by hand in the inspector, this does work, however, I need to apply this by code.

    Ideas?


     
    Last edited: Nov 22, 2018