- Home /
Duplicate Question
inheritance ? (how to do it in javascript)
I'm kinda new to Javascript and scripting in general, but I have been programming in c++ a couple of years ago, so I did things kinda different than I'm doing now in Unity, so I may be asking weird things.
I made a script to control the playercharacter (in javascript), but now I want to make a script for an npc, and I want it to be a sub-class of the player class (well actually I want to make a baseclass (superclass) and have both the player and npc inherit from it)
but how do I that ? I never actually declare any class, I just start writing in seperate scripts as if those are classes.
I tried: public class NPCBoarderScript : PlayerScript but that doesn't work
Dupe question, already answered here: http://answers.unity3d.com/questions/92/does-unity-support-inheritance-and-subclassing (voted to close)
ah, sorry, and thanks
and it appears I just have to type "extends" ins$$anonymous$$d of ":" to inherit
Answer by IJM · Oct 16, 2010 at 07:00 PM
http://download.oracle.com/javase/tutorial/java/IandI/subclasses.html
p.s. Google is your firned ;)
my firned ? :p yeah I know, sorry, should I've searched first
This is incorrect, you are referring to a link about JAVA inheritance, NOT javaSCRIPT inheritance!
Follow this Question
Related Questions
Gui Text Script 4 Answers
Unity 4.6b20 - Inheritance not working? 1 Answer
Defining and inheriting from a Javascript Class 0 Answers
C# Inheritance Question 2 Answers
How to store a javascript in a variable in the editor then call a function from it? 2 Answers