-
Notifications
You must be signed in to change notification settings - Fork 0
/
HumveeController.cs
37 lines (34 loc) · 1.11 KB
/
HumveeController.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HumveeController : MonoBehaviour {
private Rigidbody rb;
public WheelCollider FR;
public WheelCollider FL;
public WheelCollider RR;
public WheelCollider RL;
public float steerMax = 20f;
public float motorMax = 1000f;
public float brakeMax = 100f;
private float steer = 0f;
private float motor = 0f;
private float brake = 0f;
private Vector3 ra = new Vector3(1, 0, 0);
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
steer = Mathf.Clamp(Input.GetAxis("Horizontal"), -1, 1);
motor = Mathf.Clamp(Input.GetAxis("Vertical"), -1, 1);
//brake = -1 * Mathf.Clamp(Input.GetAxis("Vertical"), -1, 0);
float torque = motorMax * motor;
FR.motorTorque = torque;
FL.motorTorque = torque;
FR.steerAngle = steerMax * steer;
FL.steerAngle = steerMax * steer;
//RL.brakeTorque = brakeMax * brake;
//RR.brakeTorque = brakeMax * brake;
}
}