public void Move(float time, Vector2 netForce, bool allowWallRunning) { if (recording) { records.Add(MakeRecord(netForce, time, allowWallRunning)); } else if (playingBack) { LoadRecord(records[playbackIndex], ref netForce, ref allowWallRunning); } data.Clear(); data.SetIndex(-2); if (!SupportedByWall()) { CheckForSupport(netForce.normalized, allowWallRunning); } data.AddRecord(MakeRecord(netForce, time, allowWallRunning)); data.SetIndex(-1); if (allowWallRunning && !supported) { CheckWallCling(netForce.normalized); if (wallOnLeft || wallOnRight) { UpdateNormal(WallNormal(), netForce.normalized, allowWallRunning); } } data.AddRecord(MakeRecord(netForce, time, allowWallRunning)); int iteration = 0; for (; iteration < iterationCount; iteration++) { data.SetIndex(iteration); data.AddRecord(MakeRecord(netForce, time, allowWallRunning)); // Do not move into the slope we are running parallel to. Vector2 displacement = (velocity + netForce * time) * time; if (supported) { float normalMovement = Vector2.Dot(displacement, supportNormal); if (normalMovement < 0) // Moving into the platform we are supported by. { displacement -= normalMovement * supportNormal; } } if (CastAndMove(displacement, netForce, allowWallRunning, ref time)) { iteration++; break; } } data.SetIndex(iteration); CheckWallCling(netForce.normalized); if (allowWallRunning && (!supported || SupportedByWall())) { if (wallOnLeft || wallOnRight) { UpdateNormal(WallNormal(), netForce.normalized, allowWallRunning); } } data.AddRecord(MakeRecord(netForce, time, allowWallRunning)); }