Cant add script behaviour

Cant add script behavior
AuthorityOnSpawnedObjectIsCorrect. The script needs to derive from MonoBehaviour.

Thanks for helping if you can

-Dominic

Does AuthorityOnSpawnedObjectIsCorrect derive from MonoBehaviour?

The class inside the script must look like the following:

public class ClassName : MonoBehaviour
{

}

As Kurt said, the ': MonoBehavior’ after the class’s name signifies it derives from MonoBehaviour, which is the Unity script base class. All scripts attached to GameObjects must derive from MonoBehavior.

1 Like

Hi guys. I am a beginner at scripting code. I found this error: Can’t add script behaviour authorityonspawnedobjectiscorrect. the script needs to derive from monobehaviour.
I already trying looking for the answer. and i already try all of it and i still can’t fix it. Can someone give me some suggestion how to fix it? I using Unity 2018.4.f1. And i using asset from Tanks!

What does the class AuthorityOnSpawnedObjectIsCorrect look like then?

I am not even sure where you’re getting that AuthorityOnSpawnedObjectIsCorrect class from. It’s not part of the TANKS demo and the only place I can find it is in some unit tests related to Oculus VR integration.

The AuthorityOnSpawnedObjectIsCorrect in that case is not a MonoBehavior and thus cannot be added, but I have no idea why you’re seeing the error with the screencaps you show.

Perhaps try right-click and reimport all?

You have compiler errors, that’s why you can’t add anything. (look at/click on the bar on the bottom of the window) It looks like you have duplicated script files somewhere.

1 Like