You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Driftology/Assets/Scripts/SteeringSliderController.cs

27 lines
715 B
C#

using UnityEngine;
using UnityEngine.UI;
public class SteeringSliderController : MonoBehaviour
{
public Slider _steeringSlider;
public VehicleController _linkedController;
public Text _steeringFactorText;
private void Start()
{
if (_steeringSlider != null && _linkedController != null)
{
_steeringSlider.onValueChanged.AddListener(UpdateSteeringFactor);
UpdateSteeringFactor(_steeringSlider.value);
}
}
private void UpdateSteeringFactor(float newValue)
{
_linkedController.steeringFactor = newValue;
if (_steeringFactorText != null)
_steeringFactorText.text = $"Steering Factor: {newValue:F2}";
}
}