fgm24/Assets/Scripts/Rumbling/RopeRumbling.cs

49 lines
1.1 KiB
C#
Raw Normal View History

2024-02-04 06:12:13 +01:00
using System.Collections;
using System.Linq;
using UnityEngine;
using UnityEngine.InputSystem;
public class RopeRumbling : MonoBehaviour
{
[SerializeField] private float RopeRubleTolerance = 0.5f;
[SerializeField] private float MaxVibration = 0.8f;
private PlayerInput pInput;
private Gamepad pad;
// Rope
[SerializeField] private RopeSimulator rope;
private void Start()
{
Invoke("LateStart", 0.1f);
}
void LateStart()
{
pInput = GetComponent<PlayerInput>();
pad = Gamepad.all.ElementAtOrDefault(pInput.PlayerNum);
if (pad == null)
{
this.enabled = false;
}
else
{
}
hasInit = true;
}
bool hasInit = false;
private void Update()
{
if (!hasInit) return;
float ropeClamed = Mathf.Max(0, rope.Overshoot);
float sensitive_mapped = ropeClamed.Remap(0.2f, 1f, 0f, MaxVibration);
2024-02-04 06:50:33 +01:00
float mapped = ropeClamed.Remap(0.9f, 1f, 0f, MaxVibration);
RumbleManager.StartRumble(-1, mapped, sensitive_mapped, 0.1f);
2024-02-04 06:12:13 +01:00
}
}