using Controller.Bicycle; using JetBrains.Annotations; using UnityEngine; using UnityEngine.InputSystem; namespace Controller { [RequireComponent(typeof(PlayerInput))] [RequireComponent(typeof(IBicycleController))] public class GamepadBikeController : MonoBehaviour { public bool useSpeed; public bool useSteer; public bool useLean; public float speedMultiplier = 200f; public float leanMultiplier = 20f; public float steerMultiplier = 15f; private float acceleration; private float lean; private float steer; private IBicycleController bicycleController; private void Start() { bicycleController = GetComponent(); } private void Update() { if (useSteer) bicycleController.CurrentSteerAngle = steer; if (useLean) bicycleController.CurrentLeaningAngle = lean; if (useSpeed) bicycleController.CurrentSpeed += acceleration; } [UsedImplicitly] public void OnSpeed(InputValue value) { acceleration = value.Get() * speedMultiplier; } [UsedImplicitly] public void OnLean(InputValue value) { lean = value.Get() * leanMultiplier; } [UsedImplicitly] public void OnSteer(InputValue value) { steer = value.Get() * steerMultiplier; } } }