HingeJoint motor will not change values?
Am i missing something here? The values on the hingejoint are not changing..
public float force;
public float speed;
public Text forceValue;
public Text speedValue;
public Toggle useMotor;
void Start()
{
}
// Update is called once per frame
void Update()
{
var objects = GameObject.FindGameObjectsWithTag("clone");
foreach (var obj in objects)
{
if (obj.GetComponent<HingeJoint>() != null)
{
var hinge = obj.GetComponent<HingeJoint>();
var motor = hinge.motor;
motor.force = force;
motor.targetVelocity = speed;
}
}
forceValue.text = force.ToString();
speedValue.text = speed.ToString();
}
public void AdjustForce(float newForce)
{
force = newForce;
}
public void AdjustSpeed(float newSpeed)
{
speed = newSpeed;
}
I have the same problem.
If i change the values in the inspector, all works fine.
But when try to change the motor.targetvelocity from code, it does not change... Unity manual says exactly how to do it, but its not working....
Answer by tormentoarmagedoom · Jan 09 at 09:32 AM
Hello,
After so many tries, i think Unity 2021.2.7f1 is broken.... All parameters from the motor can be changed via script except for the targetvelocity, which does not change by code..
Your answer
Follow this Question
Related Questions
[Absolute beginner] Play animation on trigger (trigger = several fallen objects) script 1 Answer
Why does Debug.Log continue to execute from Start() and why does InvokeRepeating() not? 1 Answer
How to get an object and align it perfectly on another object with arrow button 0 Answers
Jump animation not returning to normal? 0 Answers