#I m calling this on an `OnTriggerEvent`
1 messages ยท Page 1 of 1 (latest)
EDIT: nvm
Also I wouldn't compare Quaternion's individual components (x,y,z,w)
So I would use eulerAngles.y instead
usually i would use
yield return null;
for waiting one frame
true it works, I think the problem is here:
while (DoorToOpen.transform.rotation.y != targetRotation.y)
@sour elk are you sure you are calling it with StartCoroutine()?
yeah StartCoroutine(OpenDoorOverTime(targetRotation));
loggin both the current and target rotation.y it doesn't count down, they are both 0 on the first iteration
while (!Mathf.Approximately((DoorToOpen.transform.rotation.y, targetRotation.y)
try replacing your while (DoorToOpen.transform.rotation.y != targetRotation.y)
while (Mathf.Abs(DoorToOpen.transform.eulerAngles.y - targetRotation.eulerAngles.y) > 0.001f)
@blazing spear yeah your way is cleaner. I would still use eulerAngles tho, just because i dont know how quaternion works (does Y even correspond to y axis?)
still opens straight away.. and the logs still show 0 for both on the first iteration.
it's like the iteration isn't even happening!
the quaternion axis and euler axis are not the same so using eulerAngles is probably the better way
oh
i think i'm an idiot
Quaternion targetRotation = DoorToOpen.transform.rotation *= Quaternion.Euler(0, -90, 0);
Would that be setting the transform?
*= hmm
I'm doing that to calculate the target rotation
oh man.
i've been writing code for about 15 years...
and i still suck at it ๐
thanks everyone.
happens to the best of us.
glad you found the issue ๐