Files

38 lines
924 B
C#

using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
public sealed class PlayerCarryController : NetworkBehaviour, IPlayerSystem
{
private bool isInitialized;
public void Initialize(PlayerFacade facade)
{
isInitialized = true;
}
private void Update()
{
if (!isInitialized || !IsOwner || Keyboard.current == null)
return;
if (!Keyboard.current.gKey.wasPressedThisFrame)
return;
if (NetworkHeldInteractable.TryGetHeldObject(
OwnerClientId,
out NetworkHeldInteractable heldObject))
{
heldObject.RequestThrow();
return;
}
if (NetworkDraggableInteractable.TryGetDraggedObject(
OwnerClientId,
out NetworkDraggableInteractable draggedObject))
{
draggedObject.RequestRelease();
}
}
}