Skip to content

Instantly share code, notes, and snippets.

@SocketWeaver
Last active May 11, 2019 21:37
Show Gist options
  • Save SocketWeaver/b75dc8f93fb6d000740ec789c46acbef to your computer and use it in GitHub Desktop.
Save SocketWeaver/b75dc8f93fb6d000740ec789c46acbef to your computer and use it in GitHub Desktop.
CarMovement changes
NetworkID networkId;
private void Start()
{
Rigidbody rb = GetComponent<Rigidbody>();
rb.centerOfMass = centerOfMass.localPosition;
gameSceneManager = FindObjectOfType<GameSceneManager>();
// initialize networkId
networkId = GetComponent<NetworkID>();
if (networkId.IsMine)
{
// set camera target
Camera cam = Camera.main;
CameraFollow camFollow = cam.GetComponent<CameraFollow>();
camFollow.target = transform;
}
else
{
// disable collider for remote copy
frontRightCollider.enabled = false;
frontLeftCollider.enabled = false;
rearRightCollider.enabled = false;
rearLeftCollider.enabled = false;
}
}
private void Update()
{
// update when game is started
if(gameSceneManager.State == GameSceneManager.GameState.started)
{
// only process user input if the local player is the owner of the Car GameObject
if (networkId.IsMine)
{
UpdateWheelPhysics();
}
UpdateWheelTransforms();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment