feat: drop head
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user