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.

39 lignes
1014B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionJumpTo : ActionSequence
  5. {
  6. protected Vector3 point;
  7. float height;
  8. int jumps;
  9. public ActionJumpTo(Vector3 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
  10. : base(new Action[tgtJumps])
  11. {
  12. point = tgtPoint;
  13. jumps = tgtJumps;
  14. height = tgtHeight;
  15. duration = tgtDuration;
  16. }
  17. public override Action clone()
  18. {
  19. return new ActionJumpTo(point, height, jumps, duration);
  20. }
  21. public override void start()
  22. {
  23. float coeff = 1F / jumps;
  24. Vector3 start = target.gameObject.transform.position;
  25. Vector3 end = (point - start) * coeff;
  26. Vector3 cp1 = Vector3.up * height;
  27. Vector3 cp2 = end + cp1;
  28. ActionBezierRel singleJump = new ActionBezierRel(cp1, cp2, end, duration * coeff);
  29. for (int i = 0; i < jumps; i++)
  30. {
  31. actions[i] = singleJump;
  32. }
  33. base.start();
  34. }
  35. }