How do I add a reference object's angle to another object without getting an infinity loop??
I have a needle, or object that is pointing to 0 degrees that equals its rotation on the Z axis. The needle's angle can vary depending on what is going on, so it needs to be referenced for my script so the visuals are correct.
I have another object that is rotated to reference "power". Reference hColl.
I want to add the two values to display on a gauge "torque". This is TorqueNeedle.
The problem is when I add the needles' transform.rotation.z to "power" the needle rotates faster and faster and never stops.
I want to add the two values together to get a whole number. Any ideas? Script I am using is below. colAngle = -HelicopterControllerScript.hColl; TorqueNeedlePreviousAngle = TorqueNeedle.transform.eulerAngles; float newangle = TorqueNeedlePreviousAngle.z + colAngle; TorqueNeedle.transform.localRotation = Quaternion.Euler(0, 180, newangle);
The real problem is that I have another script that controls the animation of the TorqueNeedle. Its angle can vary from 0 - 45 degrees. This is the reason I cant just add the value hColl to the rotation.
The math just goes into an infinity loop, and the value exponentially increases.
Your answer
Follow this Question
Related Questions
Is it possible to "Subscribe" and unsubscribe to a SUM calculation based on bool? 0 Answers
Trying to dynamically animate a Gimbal? 0 Answers
+= operator on transform.localPosition results in random values 1 Answer
Clamping Wrapping Rotation to Fixed Angle 0 Answers
Access Animation From Another Script 1 Answer