[Closed] Float Script Rotation Controller
I have the following situation. The rotation of Object1 on X axis depends on the movement of another Object2 by Y axis. I’ve create a Float script on the X_Rotation controller of Object 1. Here is the script
local xRot = 0
if Distance < 10 then – Distance is the distance of Object1’s World Z position
xRot += Move – Move is the movement of Object2 by the Y Axis
else
xRot += 0
I wan’t the Object1 to not rotating if the Distance is more than 10 and I would like it to stay on the last rotation angle value, which it had before Distance becomes more than 10.
I tried to use following method by adding the new variable “b” and try to set on it the rotation angle value when Distance becomes equal to 10.
float b = xRot;
if Distance > 10 then
xRot = Move;
else
xRot = b;
The Script must work in Float Script Controller and run line by line, from the top to bottom.
The problem is – I can’t set the value of Rotation angle to “b” and save it for last condition.
Is there any way to avoid this problem
P. S. I want to create the wheel on the end of the foot of my character and when the foot is lifting up then I want the wheel not rotating but keeping the last rotation angle.