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;
|
|
|
|
}
|
2024-02-04 10:24:38 +01:00
|
|
|
|
|
|
|
//StartCoroutine(RumbleLoop());
|
2024-02-04 06:12:13 +01:00
|
|
|
|
|
|
|
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 10:24:38 +01:00
|
|
|
float mapped = ropeClamed.Remap(0.5f, 1f, 0f, MaxVibration);
|
|
|
|
RumbleManager.StartRumble(-1, mapped, sensitive_mapped, 0.1f);
|
|
|
|
|
|
|
|
//float ropeClamed = Mathf.Max(0, rope.Overshoot);
|
|
|
|
//float sensitive_mapped = ropeClamed.Remap(0.2f, 0.8f, 0f, MaxVibration);
|
|
|
|
//float mapped = ropeClamed.Remap(0.9f, 1f, 0f, MaxVibration);
|
|
|
|
//rumbleStrength = sensitive_mapped;
|
2024-02-04 06:12:13 +01:00
|
|
|
}
|
2024-02-04 10:24:38 +01:00
|
|
|
|
|
|
|
//float rumbleStrength = 0;
|
|
|
|
//private IEnumerator RumbleLoop()
|
|
|
|
//{
|
|
|
|
// while (true)
|
|
|
|
// {
|
|
|
|
// if (rumbleStrength > 0.1f)
|
|
|
|
// {
|
|
|
|
// RumbleManager.StartRumble(-1, 0, rumbleStrength, 0.025f);
|
|
|
|
// }
|
|
|
|
// yield return new WaitForSecondsRealtime(0.2f);
|
|
|
|
// }
|
|
|
|
//}
|
2024-02-04 06:12:13 +01:00
|
|
|
}
|