Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 23, 2012 at 10:44 AM by duck for the following reason:

Duplicate Question

avatar image
0
Question by Steven-1 · Oct 16, 2010 at 01:42 PM · javascriptinheritanceflagged-for-closesubclass

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image duck ♦♦ · Oct 16, 2010 at 02:11 PM 0
Share

Dupe question, already answered here: http://answers.unity3d.com/questions/92/does-unity-support-inheritance-and-subclassing (voted to close)

avatar image Steven-1 · Oct 16, 2010 at 06:00 PM 0
Share

ah, sorry, and thanks

and it appears I just have to type "extends" ins$$anonymous$$d of ":" to inherit

1 Reply

  • Sort: 
avatar image
0

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 ;)

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Steven-1 · Oct 16, 2010 at 08:44 PM 0
Share

my firned ? :p yeah I know, sorry, should I've searched first

avatar image yuriks · Sep 14, 2011 at 06:21 PM 2
Share

Javascript isn't Java.

avatar image Oskar Lundqvist · Jun 20, 2013 at 09:50 AM 1
Share

This is incorrect, you are referring to a link about JAVA inheritance, NOT javaSCRIPT inheritance!

avatar image juanvillegas · Sep 17, 2013 at 05:54 PM 1
Share

hahah java is your friend, but use it correctly..

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges