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 /
avatar image
1
Question by DocteurCox · Jun 26, 2013 at 02:18 PM · collidercomponentapibehaviour

Why does Collider derives from Component instead of Behaviour ?

Hello there !

As the title says, I would like to know why Collider derives from Component instead of Behaviour, since it has an enabled property. Isn't the difference between Component and Behaviour the fact that a Component is not disableable while a Behaviour is ? Or did I misunderstand API's architecture ?

Thanks in advance for your answers :)

(yeah, that question is useless, I'm just being curious :)

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 amphoterik · Jun 26, 2013 at 02:23 PM 0
Share

Components can be disabled. It is the same as unchecking them in the inspector view.

avatar image DocteurCox · Jun 26, 2013 at 02:33 PM 0
Share

Nope, the doc is quite clear about that.

No enabled property in Component (Transform is a typical component) : http://docs.unity3d.com/Documentation/ScriptReference/Component.html

It is clearly stated that Behaviour differs from Component because they can be disabled : http://docs.unity3d.com/Documentation/ScriptReference/Behaviour.html

Considering this, I have difficulties understanding why Collider derives from Component, but there has to be good reasons :)

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jun 26, 2013 at 02:34 PM

It's more a conceptual thing. A Behaviour is usually an active component that controls the Behaviour of the GameObject. A Collider is a passive Component. It doesn't do anything. It's just "used" by other active Components like the Rigidbody.

I know the Rigidbody isn't a Behaviour either, but i guess it was a compromise since a Physics object can't really be disabled. Even as kinematic Rigidbody it's still an active component.

The class hierarchy might not be perfect, but i guess behind every decision they made there's at least some kind of reason / sense ;)

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 DocteurCox · Jun 26, 2013 at 02:42 PM 0
Share

Well, I guess that make sense, thanks for your answer :)

avatar image equalsequals · Jun 26, 2013 at 03:10 PM 0
Share

It's also important to note that Components do not receive any of the events such as OnCollisionEnter, OnEnable, etc.

I've found that it's easier to wrap your head around when learning Unity to understand that a Component is the most raw form of an object that can be attached to a GameObject, and that it really exists as a layer below and beside your implementation code that allows you to communicate with the engine.

In almost all cases (except very advanced), there is no reason for your implementation to derive from Component directly, as a $$anonymous$$onoBehaviour is a Component inherently, and $$anonymous$$onoBehaviours have access to all of the engine's messages which are vital to the game logic.

avatar image DocteurCox · Jun 26, 2013 at 03:24 PM 2
Share

Actually, I don't think it's even possible for the user to attach a custom non-$$anonymous$$onoBehaviour based component.

avatar image equalsequals · Jun 26, 2013 at 03:36 PM 0
Share

Yes you are correct. For a time I thought that was possible if you were integrating some low-level plugin but it definitely appears to have some system-level safeguard there preventing it from even happening.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Performance: Addcomponent BoxCollider in update method 0 Answers

Generic way to get properties on Component? 3 Answers

2D Animation does not start 1 Answer

Works after restart then crashes again ! "There is no 'Collider attached... a script is trying to access it" 0 Answers

Internal collisions 1 Answer


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