Last active
May 11, 2019 21:37
-
-
Save SocketWeaver/b75dc8f93fb6d000740ec789c46acbef to your computer and use it in GitHub Desktop.
CarMovement changes
This file contains hidden or 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
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