Files
project-reset/Assets/Scripts/Items/ItemDrop.cs
2025-09-08 16:40:13 -04:00

39 lines
956 B
C#

using System;
using Unity.Netcode;
using UnityEngine;
namespace Reset.Items{
public class ItemDrop : NetworkBehaviour, IInteractable{
public Item item;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start(){
}
// Update is called once per frame
void Update(){
}
public void Interact(){
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsConnectedClient) {
Debug.Log("RPC Sent");
DestroyOnOwnerRpc();
} else {
Debug.Log("Destroyed");
Destroy(gameObject);
}
}
public void CancelInteract(){
throw new NotImplementedException();
}
[Rpc(SendTo.Owner)]
public void DestroyOnOwnerRpc(){
Destroy(gameObject);
}
}
}