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
0
Question by Rphysx · Mar 29, 2014 at 06:41 PM · c#methodvoidoverride

OnTriggerEnter2D(collidertype coll) C#

Hi, I'm very new to the unity engine and I'd like to ask the community a simple question that bugs me a bit. I've studied c# with console programs and then moved to forms, and i'm generally used to create the "engine" of my applications, this is why I find it hard to understand for example how this method works.

What is exactly that calls this method and why? A particular delegate/event ? Is there some documentation that explain exactly how those kinds of methods works/gets called by the unity engine ?

Most important : If that is an inherited method from monobehaviour, why we're not supposed to override it ?

Comment
Add comment
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

2 Replies

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

Answer by Corentin · Mar 29, 2014 at 09:50 PM

I guess you want a detailed explanation, and I'm not technical enough to give it, but you should consider those method as events, not as overriding a default base behaviour.

Start,Update, OnGUI etc... don't have to override anything, they are events called by the engine.

As to what exactly calls them, how the internals work and everything, I'll let some expert answer...

Comment
Add comment · 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
0

Answer by getyour411 · Mar 29, 2014 at 06:42 PM

void is not a method, it means "this function is not required to return something"

Compare:

 public void NoReturnNeeded()

vs.

 public bool BoolReturnNeeded()
 ///
 return bool;

Please review any of the scripting and language primers for more info.

Edit: Original question has been modified...

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 Rphysx · Mar 29, 2014 at 06:49 PM 0
Share

Please consider that this is not exactly what I asked for, I know that void functions doesn't have return types

avatar image getyour411 · Mar 29, 2014 at 06:50 PM 0
Share

Now that you've modified your original post, shall I point you to the doc for OnTrigger or the basics on Triggers and Collision events? Or will you then change your next again.

avatar image Rphysx · Mar 29, 2014 at 06:54 PM 0
Share

"If that is an inherited method from monobehaviour, why we're not supposed to override it ?" Whatever answer this one is fine, I just deleted the "void" words in the question to avoid further misleadings

avatar image getyour411 · Mar 29, 2014 at 09:26 PM 0
Share

Search UA/Google: unity override mono functions

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

21 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 avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Can't override GetHashCode (cannot change return type when overriding method int UnityEngine.Object.GetHashCode") 1 Answer

How can I write: if this method (X) is activated by another specific method (Y) do this (z) 1 Answer

My function doesn't appears in the OnClick button script 5 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