DealingDamageOnContact Script

Hi

My script worked fine, but I was a bit confused. Given that this script relies on Unity.netcode and it gets a NetworkObject, had I created this myself I would have used NetworkBehaviour rather than MonoBehaviour. So in brief I am obviously confused as when I MUST use NetworkBehaviour.

(BTW enjoying the course)

Matt

Hi there,
The dealing damage on contact script only runs locally. It does not send or receive any messages over the network, so it does not need to be a NetworkBehaviour.

At a basic level, we inherit from NetworkBehaviour when we are planning on using methods or data stored in the NetworkBehaviour class. In this case, we don’t use any of those methods, so it’s not necessary. We do access the NetworkObject class, so we do need the Unity.Netcode using statement.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms