Skip to content

Instantly share code, notes, and snippets.

@SocketWeaver
Last active May 11, 2019 21:10
Show Gist options
  • Save SocketWeaver/e2e1d010bc0ec9e5806e7aa39b99325a to your computer and use it in GitHub Desktop.
Save SocketWeaver/e2e1d010bc0ec9e5806e7aa39b99325a to your computer and use it in GitHub Desktop.
CarMovement change for wheel rotation
// 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