void Start() { playerState = GetComponent <Car>().playerState; valueTracker = DebugValueTracker.Instance; if (playerState == null) { drivingEnabled = true; } Speed = 0; WheelOrientation = 0; input = GetComponent <CarPlayerInput>(); rb = GetComponent <Rigidbody>(); wheels = GetComponentsInChildren <CarWheel>(); vectorTracker = GetComponent <DebugVectorTracker>(); playerState.mode .Where(mode => mode == PlayerState.PlayerMode.Racing) .Subscribe(_ => { drivingEnabled = true; }) .AddTo(this); playerState.mode .Where(mode => mode == PlayerState.PlayerMode.Finished) .Subscribe(_ => { drivingEnabled = false; }) .AddTo(this); }
void Awake() { if (Instance != null) { gameObject.SetActive(false); return; } Instance = this; debugText = GetComponent <Text>(); }