You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
872 B
33 lines
872 B
using System; |
|
using UnityEngine; |
|
using UnityStandardAssets.CrossPlatformInput; |
|
|
|
namespace UnityStandardAssets.Vehicles.Car |
|
{ |
|
[RequireComponent(typeof (CarController))] |
|
public class CarUserControl : MonoBehaviour |
|
{ |
|
private CarController m_Car; // the car controller we want to use |
|
|
|
|
|
private void Awake() |
|
{ |
|
// get the car controller |
|
m_Car = GetComponent<CarController>(); |
|
} |
|
|
|
|
|
private void FixedUpdate() |
|
{ |
|
// pass the input to the car! |
|
float h = CrossPlatformInputManager.GetAxis("Horizontal"); |
|
float v = CrossPlatformInputManager.GetAxis("Vertical"); |
|
#if !MOBILE_INPUT |
|
float handbrake = CrossPlatformInputManager.GetAxis("Jump"); |
|
m_Car.Move(h, v, v, handbrake); |
|
#else |
|
m_Car.Move(h, v, v, 0f); |
|
#endif |
|
} |
|
} |
|
}
|
|
|