Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     carMovement   = GetComponent <CarMovement>();
     rigidbody     = GetComponent <Rigidbody>();
     gameUiManager = FindObjectOfType <UIManager>().GameUiManager;
     vcam          = FindObjectOfType <CinemachineVirtualCamera>();
     noise         = vcam.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>();
     material      = GetComponentInChildren <MeshRenderer>().material;
     currentLife   = maxLife;
     gameUiManager.DisplayLife(maxLife, currentLife);
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (GameManager.Instance.CurrentState == GameManager.GameState.GAME)
     {
         float rotationInput = Input.GetAxis("Horizontal");
         float speedInput    = Input.GetAxis("Vertical");
         if (nbCarShake > 0)
         {
             carShakeTimer += Time.deltaTime * currentCarFrequencyGain;
             transform.Rotate(Vector3.forward, Mathf.Sin(carShakeTimer) * currentCarAmplitudeGain);
         }
         else
         {
             transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
             carMovement.Movement(rotationInput, speedInput);
         }
         gameUiManager.DisplaySpeed(carMovement.CurrentSpeed / carMovement.MaxSpeed);
         gameUiManager.DisplayLife(maxLife, Mathf.Abs(currentLife));
     }
 }