new input system working
This commit is contained in:
@@ -211,6 +211,34 @@ public partial class @InputMaster: IInputActionCollection2, IDisposable
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Quit"",
|
||||
""id"": ""438f3b6d-0c7f-4b9a-8ad9-e9f579d301c1"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Quit"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""70626aec-c0b2-4b69-8178-0cf47115bc24"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""a9d6f446-7259-4075-aa28-d6c782ee269a"",
|
||||
""path"": ""<Keyboard>/escape"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Quit"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": [
|
||||
@@ -248,6 +276,9 @@ public partial class @InputMaster: IInputActionCollection2, IDisposable
|
||||
m_Car_Movement = m_Car.FindAction("Movement", throwIfNotFound: true);
|
||||
m_Car_Turn = m_Car.FindAction("Turn", throwIfNotFound: true);
|
||||
m_Car_Brake = m_Car.FindAction("Brake", throwIfNotFound: true);
|
||||
// Quit
|
||||
m_Quit = asset.FindActionMap("Quit", throwIfNotFound: true);
|
||||
m_Quit_Quit = m_Quit.FindAction("Quit", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -367,6 +398,52 @@ public partial class @InputMaster: IInputActionCollection2, IDisposable
|
||||
}
|
||||
}
|
||||
public CarActions @Car => new CarActions(this);
|
||||
|
||||
// Quit
|
||||
private readonly InputActionMap m_Quit;
|
||||
private List<IQuitActions> m_QuitActionsCallbackInterfaces = new List<IQuitActions>();
|
||||
private readonly InputAction m_Quit_Quit;
|
||||
public struct QuitActions
|
||||
{
|
||||
private @InputMaster m_Wrapper;
|
||||
public QuitActions(@InputMaster wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Quit => m_Wrapper.m_Quit_Quit;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Quit; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(QuitActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IQuitActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_QuitActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_QuitActionsCallbackInterfaces.Add(instance);
|
||||
@Quit.started += instance.OnQuit;
|
||||
@Quit.performed += instance.OnQuit;
|
||||
@Quit.canceled += instance.OnQuit;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IQuitActions instance)
|
||||
{
|
||||
@Quit.started -= instance.OnQuit;
|
||||
@Quit.performed -= instance.OnQuit;
|
||||
@Quit.canceled -= instance.OnQuit;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IQuitActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_QuitActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IQuitActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_QuitActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_QuitActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public QuitActions @Quit => new QuitActions(this);
|
||||
private int m_GamepadSchemeIndex = -1;
|
||||
public InputControlScheme GamepadScheme
|
||||
{
|
||||
@@ -391,4 +468,8 @@ public partial class @InputMaster: IInputActionCollection2, IDisposable
|
||||
void OnTurn(InputAction.CallbackContext context);
|
||||
void OnBrake(InputAction.CallbackContext context);
|
||||
}
|
||||
public interface IQuitActions
|
||||
{
|
||||
void OnQuit(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,34 @@
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Quit",
|
||||
"id": "438f3b6d-0c7f-4b9a-8ad9-e9f579d301c1",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Quit",
|
||||
"type": "Button",
|
||||
"id": "70626aec-c0b2-4b69-8178-0cf47115bc24",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "a9d6f446-7259-4075-aa28-d6c782ee269a",
|
||||
"path": "<Keyboard>/escape",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Quit",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
|
||||
@@ -916,7 +916,7 @@ PlayerSettings:
|
||||
hmiLogStartupTiming: 0
|
||||
hmiCpuConfiguration:
|
||||
apiCompatibilityLevel: 6
|
||||
activeInputHandler: 1
|
||||
activeInputHandler: 2
|
||||
windowsGamepadBackendHint: 0
|
||||
cloudProjectId:
|
||||
framebufferDepthMemorylessMode: 0
|
||||
|
||||
Reference in New Issue
Block a user