Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grindingDir = tempElement.ProgressionToWorldDirection(grindableProgression);
- targetPos = targetPos + (grindingDir * grindableSpeed * Time.fixedDeltaTime);
- targetPos = tempElement.GetNearestPointToElement(targetPos, grindableProgression, out tempElement);
- if (tempElement != null) { targetRot = Quaternion.LookRotation(grindingDir, tempElement.GetElementUpAtPos(targetPos)); }
- else { targetRot = Quaternion.LookRotation(grindingDir, grindingWithTrick.GetElementUpAtPos(targetPos)); }
- // We keep the grindtrick adjustments away from targetPos/Rot, so that our grind can continue smoothly along the element
- Vector3 adjustedPos = targetPos;
- Quaternion adjustedRot = targetRot;
- Vector3 adjustedRelPos = grind.RelativePos;
- Quaternion adjustedRelRot = Quaternion.Euler(grind.RelativeRot);
- // Grinds mirror front-to-back for Switch, and they ALSO mirror side-to-side based on which side of the rail we're on)
- if (skate.Movement.IsInSwitch)
- {
- adjustedRelPos.z = -adjustedRelPos.z;
- adjustedRelRot = Quaternion.Euler(0f, 180f, 0f) * Quaternion.Euler(-grind.RelativeRot.x, grind.RelativeRot.y, grind.RelativeRot.z);
- }
- if (shouldMirrorHoriz)
- {
- adjustedRelPos.x = -adjustedRelPos.x;
- adjustedRelRot = Util.MathHelper.MirrorHeading(adjustedRelRot, Vector3.left);
- }
- // Now apply the result
- adjustedPos += targetRot * adjustedRelPos;
- adjustedRot *= adjustedRelRot;
- skate.RigidBody.transform.SetPositionAndRotation(adjustedPos, adjustedRot);
Advertisement
Add Comment
Please, Sign In to add comment