Advertisement
Guest User

CarUserControl.cs

a guest
Sep 7th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using UnityStandardAssets.CrossPlatformInput;
  4.  
  5. namespace UnityStandardAssets.Vehicles.Car
  6. {
  7.     [RequireComponent(typeof (CarController))]
  8.     public class CarUserControl : MonoBehaviour
  9.     {
  10.         private CarController m_Car; // the car controller we want to use
  11.  
  12.  
  13.         private void Awake()
  14.         {
  15.             // get the car controller
  16.             m_Car = GetComponent<CarController>();
  17.         }
  18.  
  19.  
  20.         private void FixedUpdate()
  21.         {
  22.             // pass the input to the car!
  23.             float h = CrossPlatformInputManager.GetAxis("Horizontal") + Input.GetAxis("Horizontal");
  24.             float v = CrossPlatformInputManager.GetAxis("Vertical") + Input.GetAxis("Vertical");
  25.  
  26.             #if !MOBILE_INPUT
  27.                 float handbrake = CrossPlatformInputManager.GetAxis("Jump");
  28.                 m_Car.Move(h, v, v, handbrake);
  29.             #else
  30.                 m_Car.Move(h, v, v, 0f);
  31.             #endif
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement