Hi, i recently has a big problem. i searching from any forums and QA but didn’t find any luck.
so my problem is i want to move (and rotate) object by adding value on every Update()
call, this is similar like to call Vector3.Lerp()
and Quaternion.Lerp()
. And this is my code :
void Update(){
if (doTim > 0 && Time.deltaTime > 0) {
doTim -= Time.deltaTime;
if (doTim != 0) {
if (doPos)
Behaviors [behaviorCycle].objTarget.localPosition += doPosTo / (doTimTotal / Time.deltaTime);
if (doRot)
Behaviors [behaviorCycle].objTarget.localRotation *= Quaternion.Euler (doRotTo / (doTimTotal / Time.deltaTime));
if (doTim < 0) {
if (doPos)
Behaviors [behaviorCycle].objTarget.localPosition += doTim * (doPosTo / doTimTotal);
if (doRot)
Behaviors [behaviorCycle].objTarget.localRotation *= Quaternion.Euler (doTim * doRotTo / doTimTotal);
}
}
}
}
the localPosition
changes on this Update
call are WORKED correctly, but for the localRotation
, it rotation will ended with very strange value.
if I rotate it by only one Axis (say, from (0,0,0)
to (0,90,0)
) it will rotating correctly, but if I rotate it using two or more Axis (say, from (0,0,0)
to (90,90,0)
) it will returning very strange value.
so, What should I do? is there something I missed? I have trying to using Transform.Rotate()
but it did the same things.
PS : I won’t use Lerp()
function because the object are controlled by more than one script in my game.