-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarUserControl.cs
More file actions
51 lines (39 loc) · 1.1 KB
/
CarUserControl.cs
File metadata and controls
51 lines (39 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.Vehicles.Car
{
[RequireComponent(typeof (CarController))]
public class CarUserControl : MonoBehaviour
{
public float asd;
public float h;
public float v;
public float handbrake;
public float mySteering;
public CarController m_Car; // the car controller we want to use
public void Awake()
{
// get the car controller
m_Car = GetComponent<CarController>();
h = 0;
}
public void FixedUpdate()
{
// pass the input to the car!
h = CrossPlatformInputManager.GetAxis("Horizontal");
v = CrossPlatformInputManager.GetAxis("Vertical");
#if !MOBILE_INPUT
handbrake = CrossPlatformInputManager.GetAxis("Jump");
if(asd > -1)
m_Car.Move(h, v, v, handbrake);
else {
h = 0;
v = 0;
handbrake = 0;
m_Car.Move(h, v, v, handbrake); }
#else
#endif
}
}
}