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 NOVAgaming · Nov 01, 2012 at 08:46 PM · javascriptmonodevelopnewbiebasic

No custom scripts will work.*Using US.*

US = UnityScript.

I am a newbie, and made a basic script.

function OnTriggerEnter() { Debug.log("Hiya"); }

You know, BASIC. And when I play, it doesn't show an error, but it DOESN'T print in the output. Now I tried some different things, like.

var health = 10;

function OnTriggerEnter(){ health - 1; Debug.log("You lost some health dear soul."); }

The 2nd script, it made a variable named health, put it to 10, but it errors out and I can't even play the game. How come no scripts are working? yet imported ones DO work. I use MonoDevelop.

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 Polymo · Nov 01, 2012 at 08:48 PM 0
Share

The Documentation says, one of the colliders needs a rigidbody attached, did you make sure that this is the case?

avatar image NOVAgaming · Nov 01, 2012 at 08:52 PM 0
Share

No, sorry, just normal cube.

1 Reply

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

Answer by MichaelTaylor3d · Nov 01, 2012 at 08:49 PM

OnTriggerEnter is triggered when a collider that is flagged as a trigger enters the collider of your script. If you want your log message to run when you hit play. Try putting it in function Start()

 function Start()
 {
     Debug.Log("Hiya");
 }
Comment
Add comment · Show 3 · 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 NOVAgaming · Nov 01, 2012 at 08:53 PM 0
Share

Wait, what do you mean about the OnTriggerEnter? And I am guessing 'Start' means as soon as the game starts playing?

avatar image MichaelTaylor3d · Nov 01, 2012 at 08:59 PM 0
Share

that is correct Awake() runs as soon as the script is instantiated. Start() runs as soon as the script runs. OnTriggerEnter() runs when a trigger collider enters the collider of a gameobject your script is attached to.

http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.Start.html

http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.Awake.html

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html

avatar image MichaelTaylor3d · Nov 14, 2012 at 03:18 PM 0
Share

PS dont forget to accept any correct answers people give you.

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

12 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

Related Questions

Question on UnityScript and C# 1 Answer

A node in a childnode? 1 Answer

Whats a good place to learn UnityScript? 1 Answer

UnityScript auto-format? 0 Answers

Create animation clip without "using UnityEditor" 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