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.

44 lines
1.1KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. public class CalcerDirection : CalcerVector
  7. {
  8. Actor selfActor;
  9. Actor targetActor;
  10. Transform selfTransform;
  11. Transform targetTransform;
  12. public CalcerDirection(Actor self, Actor target)
  13. : base()
  14. {
  15. selfActor = self;
  16. targetActor = target;
  17. }
  18. public CalcerDirection(Transform self, Transform target)
  19. : base()
  20. {
  21. selfTransform = self;
  22. targetTransform = target;
  23. }
  24. public override Vector3 value
  25. {
  26. get
  27. {
  28. if (targetTransform != null)
  29. {
  30. return Quaternion.LookRotation(targetTransform.position - selfTransform.position).eulerAngles;
  31. }
  32. else
  33. {
  34. return Quaternion.LookRotation(targetActor.transformCached.position - selfActor.transformCached.position).eulerAngles;
  35. }
  36. }
  37. }
  38. }
  39. }