You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

32 lines
780B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionSetRotation : Action
  5. {
  6. protected Vector3 value;
  7. public ActionSetRotation(Vector3 tgtValue)
  8. : base()
  9. {
  10. value = tgtValue;
  11. }
  12. public override Action clone()
  13. {
  14. return new ActionSetRotation(value);
  15. }
  16. public override void start()
  17. {
  18. base.start();
  19. Vector3 path = new Vector3();
  20. for (int i = 0; i < 3; i++)
  21. {
  22. path[i] = value[i] - target.gameObject.transform.rotation.eulerAngles[i];
  23. }
  24. target.gameObject.transform.Rotate(Vector3.up, path.y);
  25. target.gameObject.transform.Rotate(Vector3.right, path.x);
  26. target.gameObject.transform.Rotate(Vector3.forward, path.z);
  27. }
  28. }