#I m calling this on an `OnTriggerEvent`

1 messages ยท Page 1 of 1 (latest)

sour elk
#

any thoughts?

woeful fractal
#

EDIT: nvm

#

Also I wouldn't compare Quaternion's individual components (x,y,z,w)

#

So I would use eulerAngles.y instead

blazing spear
#

usually i would use

 yield return null;

for waiting one frame

woeful fractal
#

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()?

sour elk
#

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

blazing spear
woeful fractal
#

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?)

sour elk
#

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!

blazing spear
sour elk
#

oh

#

i think i'm an idiot

#
Quaternion targetRotation = DoorToOpen.transform.rotation *= Quaternion.Euler(0, -90, 0);

Would that be setting the transform?

woeful fractal
#

*= hmm

sour elk
#

I'm doing that to calculate the target rotation

woeful fractal
#

replace *= with *

#

oh wtf

#

replace *=with *

sour elk
#

oh man.

#

i've been writing code for about 15 years...

#

and i still suck at it ๐Ÿ˜„

#

thanks everyone.

woeful fractal
#

happens to the best of us.

blazing spear
#

glad you found the issue ๐Ÿ™‚