added: item pickups with online persistency
This commit is contained in:
38
Assets/Scripts/Items/ItemDrop.cs
Normal file
38
Assets/Scripts/Items/ItemDrop.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user