public Steering2D GetSteering() { Steering2D steering = arrive.GetSteering(target); if (!steering.isMoving || IsNotMovingCloser()) { NextTarget(); steering = arrive.GetSteering(target); } return(steering); }
public Steering2D GetSteering(LinePath path, bool pathLoop = false) { Vector2 targetPosition; /* If the path has only one node then just go to that position. */ if (path.Length == 1) { targetPosition = path[0]; } /* Else find the closest spot on the path to the character and go to that instead. */ else { /* Get the param for the closest position point on the path given the character's position */ float param = path.GetParam(transform.position); //Debug.DrawLine(transform.position, path.getPosition(param, pathLoop), Color.red, 0, false); /* Move down the path */ param += pathDirection * pathOffset; /* Set the target position */ targetPosition = path.GetPosition(param, pathLoop); //Debug.DrawLine(transform.position, targetPosition, Color.red, 0, false); } return(arrive.GetSteering(targetPosition)); }