public void Execute(ref VehiclePathing p, ref VehicleTargetPosition pos) { RoadSection rs = RoadSections[p.RoadIndex]; quaternion direction = CatmullRom.GetOrientation(rs.p0, rs.p1, rs.p2, rs.p3, p.curvePos); float3 currentLane = GetOffsetFromLaneIndex(p.LaneIndex, direction, rs.width); float3 destinationLane = GetOffsetFromLaneIndex(p.WantedLaneIndex, direction, rs.width); pos.IdealPosition += math.lerp(currentLane, destinationLane, math.smoothstep(0, 1, p.LaneTween)); if (p.LaneIndex != p.WantedLaneIndex) { p.LaneTween += DeltaTimeSeconds * p.speed * 0.1f; if (p.LaneTween >= 1.0f) { p.LaneIndex = p.WantedLaneIndex; p.LaneTween = 0.0f; } } }