Last active
May 11, 2019 21:10
-
-
Save SocketWeaver/e2e1d010bc0ec9e5806e7aa39b99325a to your computer and use it in GitHub Desktop.
CarMovement change for wheel rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// expose wheel rotate for the generic tracker | |
public Quaternion frontWheelRot; | |
public Quaternion rearWheelRot; | |
void UpdateWheelTransforms() | |
{ | |
if (networkId.IsMine) | |
{ | |
Quaternion rotation; | |
Vector3 position; | |
frontLeftCollider.GetWorldPose(out position, out rotation); | |
frontLeftTransform.position = position; | |
frontLeftTransform.rotation = rotation; | |
frontRightCollider.GetWorldPose(out position, out rotation); | |
frontRightTransform.position = position; | |
frontRightTransform.rotation = rotation; | |
// update the front wheel rotation for generic tracker | |
frontWheelRot = rotation; | |
rearLeftCollider.GetWorldPose(out position, out rotation); | |
rearLeftTransform.position = position; | |
rearLeftTransform.rotation = rotation; | |
rearRightCollider.GetWorldPose(out position, out rotation); | |
rearRightTransform.position = position; | |
rearRightTransform.rotation = rotation; | |
// update the rear wheel rotation for generic tracker | |
rearWheelRot = rotation; | |
} | |
else | |
{ | |
// apply the rotations for remote copy | |
frontLeftTransform.rotation = frontWheelRot; | |
frontRightTransform.rotation = frontWheelRot; | |
rearLeftTransform.rotation = rearWheelRot; | |
rearRightTransform.rotation = rearWheelRot; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment