//----------------------------------------------
// Simple Car Controller
//
// Copyright © 2014 - 2023 BoneCracker Games
// http://www.bonecrackergames.com
//
//----------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// Input receiver through the Unity's new Input System.
///
public class SCC_InputManager : SCC_Singleton {
public SCC_Inputs inputs; // Actual inputs.
private static SCC_InputActions inputActions;
private void Awake() {
// Hiding this gameobject in the hierarchy.
gameObject.hideFlags = HideFlags.HideInHierarchy;
// Creating inputs.
inputs = new SCC_Inputs();
}
private void Update() {
// Creating inputs.
if (inputs == null)
inputs = new SCC_Inputs();
// Receive inputs from the controller.
GetInputs();
}
///
/// Gets all inputs and registers button events.
///
///
public void GetInputs() {
if (inputActions == null) {
inputActions = new SCC_InputActions();
inputActions.Enable();
}
inputs.throttleInput = inputActions.Vehicle.Throttle.ReadValue();
inputs.brakeInput = inputActions.Vehicle.Brake.ReadValue();
inputs.steerInput = inputActions.Vehicle.Steering.ReadValue();
inputs.handbrakeInput = inputActions.Vehicle.Handbrake.ReadValue();
}
}