Files
2026-03-04 10:03:45 +08:00

36 lines
714 B
C#

using Obi;
using UnityEngine;
public class CraneController : MonoBehaviour
{
private ObiRopeCursor cursor;
private ObiRope rope;
private void Start()
{
cursor = GetComponentInChildren<ObiRopeCursor>();
rope = cursor.GetComponent<ObiRope>();
}
private void Update()
{
if (Input.GetKey(KeyCode.W) && rope.restLength > 6.5f)
{
cursor.ChangeLength(rope.restLength - 1f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S))
{
cursor.ChangeLength(rope.restLength + 1f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
base.transform.Rotate(0f, Time.deltaTime * 15f, 0f);
}
if (Input.GetKey(KeyCode.D))
{
base.transform.Rotate(0f, (0f - Time.deltaTime) * 15f, 0f);
}
}
}