28 lines
661 B
C#
28 lines
661 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 &&
|
|
NetworkHeldInteractable.TryGetHeldObject(
|
|
OwnerClientId,
|
|
out NetworkHeldInteractable heldObject))
|
|
{
|
|
heldObject.RequestThrow();
|
|
}
|
|
}
|
|
}
|