Skip to content

Instantly share code, notes, and snippets.

@nilsmunch
Created November 5, 2025 15:33
Show Gist options
  • Select an option

  • Save nilsmunch/5197559663b9fe7f9ace991eb1198736 to your computer and use it in GitHub Desktop.

Select an option

Save nilsmunch/5197559663b9fe7f9ace991eb1198736 to your computer and use it in GitHub Desktop.
Crane stuff
using LizardKit.DebugButton;
using UnityEngine;
public class CraneCable : MonoBehaviour
{
public LineRenderer lineRenderer;
public Transform CraneTip;
public Transform Hook;
private void Update()
{
DrawLine();
}
[Button]
private void DrawLine()
{
lineRenderer.SetPosition(0, CraneTip.position);
lineRenderer.SetPosition(1, Hook.position);
}
}
using UnityEngine;
using UnityEngine.InputSystem;
public class CraneBaseController : MonoBehaviour
{
public float moveSpeed = 15f;
public float winceSpeed = 1f;
public SpringJoint CableWince;
void Update()
{
if (Keyboard.current.leftArrowKey.isPressed) transform.Rotate(Vector3.forward * (moveSpeed * Time.deltaTime), Space.Self);
if (Keyboard.current.rightArrowKey.isPressed) transform.Rotate(Vector3.back * (moveSpeed * Time.deltaTime), Space.Self);
if (Keyboard.current.upArrowKey.isPressed) CableWince.maxDistance -= winceSpeed * Time.deltaTime;
if (Keyboard.current.downArrowKey.isPressed) CableWince.maxDistance += winceSpeed * Time.deltaTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment