- Create the Jump script along with its member variables:
using UnityEngine; using System.Collections; public class Jump : VelocityMatch { public JumpPoint jumpPoint; public float maxYVelocity; public Vector3 gravity = new Vector3(0, -9.8f, 0); bool canAchieve = false; }
- Implement the SetJumpPoint function:
public void SetJumpPoint(Transform jumpPad, Transform landingPad) { jumpPoint = new JumpPoint(jumpPad.position, landingPad.position); }
- Add a function to calculate the target:
protected void CalculateTarget() { target = new GameObject(); target.AddComponent<Agent>(); target.transform.position = jumpPoint.jumpLocation; //Calculate the first jump time float sqrtTerm = Mathf.Sqrt(2f * gravity.y * jumpPoint.deltaPosition.y ...