IEnumerator Move(Vector2 velocity) { float timestep = _customPhysic.Timestep; ballVelocity = velocity; while (!dropped) { TrajectoryPoint nextPoint = _customPhysic.GetNextTrajectoryPoint(transform.position, ballVelocity); transform.position = nextPoint.Point; ballVelocity = nextPoint.Velocity; yield return(new WaitForSeconds(timestep)); } }
public List <TrajectoryPoint> GetTrajectory(Vector2 ballPosition, Vector2 force) { CustomPhysic customPhysic = CustomPhysic.getInstance(); List <TrajectoryPoint> trajectoryPoints = new List <TrajectoryPoint>(); TrajectoryPoint currentTrajectoryPoint = new TrajectoryPoint(ballPosition, force); trajectoryPoints.Add(currentTrajectoryPoint); for (int i = 0; i < maxSteps; i++) { currentTrajectoryPoint = customPhysic.GetNextTrajectoryPoint(currentTrajectoryPoint.Point, currentTrajectoryPoint.Velocity); trajectoryPoints.Add(currentTrajectoryPoint); } return(trajectoryPoints); }