new input system working
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Quit : MonoBehaviour
|
||||
{
|
||||
private void Update() {
|
||||
if(Input.GetKeyDown(KeyCode.Escape)) Application.Quit();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcd90519abd2eaa47ab4e721bdbe12c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -31,6 +31,23 @@ public class WheelController : MonoBehaviour
|
||||
controls = new InputMaster();
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
movement = controls.Car.Movement;
|
||||
movement.Enable();
|
||||
|
||||
turn = controls.Car.Turn;
|
||||
turn.Enable();
|
||||
|
||||
brake = controls.Car.Brake;
|
||||
brake.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
movement.Disable();
|
||||
turn.Disable();
|
||||
brake.Disable();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
debugInfo.setRpmLabels(frontLeftWheel.GetWheelRPM(), frontRightWheel.GetWheelRPM(), rearLeftWheel.GetWheelRPM(), rearRightWheel.GetWheelRPM());
|
||||
}
|
||||
@@ -39,15 +56,12 @@ public class WheelController : MonoBehaviour
|
||||
//TODO: Update input info to new input system
|
||||
|
||||
//forward reverse input
|
||||
//currentAcceleration = acceleration * Input.GetAxis("Vertical");
|
||||
//Debug.Log("movement value: " + movement.ReadValue<float>());
|
||||
currentAcceleration = acceleration * movement.ReadValue<float>();
|
||||
|
||||
|
||||
//breaking input
|
||||
/*if(Input.GetKey(KeyCode.Space)){
|
||||
currentBrakeForce = breakingForce;
|
||||
}else{
|
||||
currentBrakeForce = 0f;
|
||||
}*/
|
||||
//Debug.Log("brake: " + brake.ReadValue<float>());
|
||||
currentBrakeForce = breakingForce * brake.ReadValue<float>();
|
||||
|
||||
//apply acceleration to front wheels| (this determines which wheel drive is the car (fwd, awd, rwd))
|
||||
rearRightWheel.ApplyAcceleration(currentAcceleration);
|
||||
@@ -60,7 +74,7 @@ public class WheelController : MonoBehaviour
|
||||
rearRightWheel.ApplyBrakeForce(currentBrakeForce);
|
||||
|
||||
//steering
|
||||
//currentTurnAngle = maxTurnAngle * Input.GetAxis("Horizontal"); //getting steering input
|
||||
currentTurnAngle = maxTurnAngle * turn.ReadValue<float>(); //getting steering input
|
||||
frontLeftWheel.ApplySteerAngle(currentTurnAngle);
|
||||
frontRightWheel.ApplySteerAngle(currentTurnAngle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user