From Rotation A To Rotation B
« on: August 20, 2015, 02:53:19 AM »
I cannot figure this out for the life of me!

All I want to do is be able to rotation from my current rotation to a new rotation.

  • Arrow is at rotation z of 0.
  • Rotate from 0 to 90.
  • Arrow is now at rotation 90.
  • Rotate from 90 to 270.
  • Arrow is now at rotation 270.
  • Rotate from 270 to 180.


This is my current code.

Code: [Select]
reachedCheckpointSpinTween = this.transform.DORotate(this.transform.eulerAngles, reachedCheckpointDuration).SetRelative(true);

reachedCheckpointSpinTween.ChangeEndValue(playerController.transform.eulerAngles, 0);
reachedCheckpointSpinTween.Play();


I got it so that it works rotating 3 directions, but one direction it just snaps too. Also it keeps starting from its original position and rotating to the rotation I want.


Thanks!


*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: From Rotation A To Rotation B
« Reply #1 on: August 20, 2015, 01:10:53 PM »
Hi,

If you change the end value, only that will change, but the starting position will remain the same. You should create a new tween, so that it will re-take the starting position also.

About the "snap", if you mean that it doesn't rotate BY the amount you set, you should use the RotateMode.Beyond360 additional parameter, otherwise rotations will find the shortest route and follow that one.

Cheers,
Daniele