Issues Inheriting classes and monoBehaviour

I am trying to create a system of classes for my enemy characters. My parent class is ‘Enemy’ and the child classes are ‘Enemy1’ and ‘Enemy2’.
I can get the objects to works perfectly when I have all the functions in one big script but I want to be able to recycle existing functions from base classes instead of rewrite them every time.

I’m trying to test a simple function which works great when written in the same non custom class but when I try to extend the same function from a parent class my object does nothing and I get this error:

You are trying to create a
MonoBehaviour using the ‘new’ keyword.
This is not allowed. MonoBehaviours
can only be added using
AddComponent(). Alternatively, your
script can inherit from
ScriptableObject or no base class at
all

here’s my Two classes:

Script Enemy1

#pragma strict

class Enemy1 extends Enemy
{

	function Start () {
		
		
		Speed = 4;
	}

	function Update () {

var Poop = Enemy();
		Poop.MoveInPath();
		
	}
}

Script Enemy

#pragma strict

public class Enemy extends MonoBehaviour
{

	var Speed : int;

	function MoveInPath()
	{
		transform.Translate(Speed * Time.deltaTime, 0, 0, Camera.main.transform);
		
	}
}

Can anyone tell me what I’m doing wrong? Should I even be trying to use classes in unity’s java script?

If you just google “You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed” you’d get tons of results. The reason you can’t do that, is that when a Component is created (MonoBehaviour is a Component) there is some internal cooking/ behind the scene prepping for the the object in the unmanaged C++ side of Unity, not just a managed representation. For UnityEngine.Components you should always use AddComponent

Unity is a component-based engine. In a component-based design objects don’t exist by themselves, but they’re the sum of their individual components. It works like this: You have GameObjects (entities) - these a gameObject is basically a Component holder, it holds components. You give your objects new behaviours by adding to them new components (Rigidbody, BoxCollider, a MonoBehaviour etc)

So for you to instantiate your Enemy object, since it’s a MonoBehaviour, you’d have to add it to a gameObject via myGo.AddComponent< Enemy >(); (C#) and myGo.AddComponent.< Enemy >(); (JS) (use generic whenever you can)