45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class FishingLineTestController : MonoBehaviour
|
|
{
|
|
[SerializeField] private FishingLineSolver solver;
|
|
[SerializeField] [Min(0.01f)] private float reelSpeed = 1.5f;
|
|
[SerializeField] private KeyCode reelInKey = KeyCode.E;
|
|
[SerializeField] private KeyCode reelOutKey = KeyCode.Q;
|
|
|
|
private void Reset()
|
|
{
|
|
solver = GetComponent<FishingLineSolver>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (solver == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
float direction = 0f;
|
|
if (Input.GetKey(reelInKey))
|
|
{
|
|
direction -= 1f;
|
|
}
|
|
|
|
if (Input.GetKey(reelOutKey))
|
|
{
|
|
direction += 1f;
|
|
}
|
|
|
|
float scroll = Input.mouseScrollDelta.y;
|
|
if (Mathf.Abs(scroll) > Mathf.Epsilon)
|
|
{
|
|
direction += Mathf.Sign(scroll);
|
|
}
|
|
|
|
if (Mathf.Abs(direction) > Mathf.Epsilon)
|
|
{
|
|
solver.AdjustStartSegmentLength(direction * reelSpeed * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|