Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

40 lignes
1.2KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionBezierAbs : ActionInterval
  5. {
  6. protected Vector3 startPoint;
  7. protected Vector3 endPoint;
  8. protected Vector3 startControlPoint;
  9. protected Vector3 endControlPoint;
  10. public ActionBezierAbs(Vector3 tgtStart, Vector3 tgtSCP, Vector3 tgtECP, Vector3 tgtEnd, float tgtDuration)
  11. : base(tgtDuration)
  12. {
  13. startPoint = tgtStart;
  14. endPoint = tgtEnd;
  15. startControlPoint = tgtSCP;
  16. endControlPoint = tgtECP;
  17. }
  18. public override Action clone()
  19. {
  20. return new ActionBezierAbs(startPoint, startControlPoint, endControlPoint, endPoint, duration);
  21. }
  22. public override Action reverse()
  23. {
  24. return new ActionBezierAbs(endPoint, endControlPoint, startControlPoint, startPoint, duration);
  25. }
  26. public override void stepInterval(float dt)
  27. {
  28. float t = timer / duration;
  29. Vector3 newPosition = (((-startPoint
  30. + 3 * (startControlPoint - endControlPoint) + endPoint) * t
  31. + (3 * (startPoint + endControlPoint) - 6 * startControlPoint)) * t +
  32. 3 * (startControlPoint - startPoint)) * t + startPoint;
  33. transform.position = newPosition;
  34. }
  35. }