feat: drop head

This commit is contained in:
timote koenig
2026-03-12 10:33:37 +01:00
parent 94e44ad7af
commit 67a1717b86
9 changed files with 183 additions and 55 deletions

View File

@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using UnityEngine;
public class PlayerHeadController : MonoBehaviour
@@ -34,22 +35,27 @@ public class PlayerHeadController : MonoBehaviour
void Update()
{
if (input.HeadInteractionPressed)
{
InteractHead();
}
if (input.ThrowPressed)
{
ThrowHead();
}
if (input.PickupPressed)
{
TryPickupHead();
}
}
private void ThrowHead()
private void InteractHead()
{
if (!isHoldingHead)
return;
TryPickupHead();
else
DropHead();
}
private void DropHead()
{
animator.SetTrigger("Throw");
isHoldingHead = false;
@@ -63,6 +69,14 @@ public class PlayerHeadController : MonoBehaviour
RigidbodyConstraints.FreezeRotationX |
RigidbodyConstraints.FreezeRotationZ |
RigidbodyConstraints.FreezeRotationY;
}
private void ThrowHead()
{
if (!isHoldingHead)
return;
DropHead();
m_headRigidbody.AddForce(CameraTransform.forward * ThrowForce, ForceMode.Impulse);
}
@@ -94,4 +108,4 @@ public class PlayerHeadController : MonoBehaviour
Head.localPosition = m_headInitialLocalPos;
Head.localRotation = m_headInitialLocalRot;
}
}
}