- Home /
Question by
MrAwesome343 · Jun 21, 2016 at 01:49 AM ·
scripting problemmonobehaviourcombatmonobehaviormonobeahviour
I'm getting a warning in Unity about trying to create a MonoBehaviour using the "new" keyword. How do I fix it?
Exactly like the title. I don't know how to do the fix that it's suggesting, so I don't really know how to move forward. The error brings me here:
public class NewGame : MonoBehaviour {
private Combat newPlayer;
void Start()
{
newPlayer= new Combat();
}
Combat is the name of another script
Comment
Answer by JDAUL · Jun 21, 2016 at 02:00 AM
Your Combat class must be extending the MonoBehaviour class, in that case you need to add it to your object using AddComponent() or through the inspector.
Your answer
Follow this Question
Related Questions
Custom Inspector: Accessing a reference to another MonoBehaviour? 1 Answer
error CS0713 UnityEngine.MonoBehaviour'. Static classes must derive from object 0 Answers
OnValidate() not called Unity 5.1.0f3 2 Answers
Can anyone provide some help with that error ? 1 Answer
No Monobehaviour scripts in files 1 Answer