Hey there. I’m pretty new to Unity but I am learning how to code now. The problem is the “OnTriggerEnter” function is not working. It doesn’t even change color. I got the code from a youtube tutorial so I know it works. Heres the part of the code.
function OnTriggerEnter(other : Collider){
What doesn't change colour? I'm guessing there's some more code: edit your question, paste the code, highlight it and click the 101 button.
Hey there. The actual lettering of "OnTriggerEnter" within MonoDevelop doesn't change to orange/ blue or whatever the default is for MonoDevelop. I switched to Untron instead and it has been working fine.
Sorry my bad I (clearly) am new here I'll try not to do that anymore. But thank you for the advice I did convert it to a rigidbody and that fixed everything. (sorry if that comes off sarcastic I tend to type that way but I appreciate all of your as well as everyone's help.)
I just ran into this problem as well. In Hierarchy view, I have a parent object with one child object with the same name. Looks like I inadvertently assigned the script handling the OnTriggerEnter event to the parent object, but the collider to the child object. Adding collider to the parent object fixed it. I’m still very new, but I am surprised that having an OnTriggerEnter event in a script attached to object without collider does not generate a compile error or warning message.
(Unity Version 4.1.2f1)
Nope it will never generate a warning or error, because that's not how Unity operates with its component model. At any moment during gameplay you could add a collider or remove a collider or add a rigidbody to that object (or enable or disable them).
I should point out that your could flag your script as [ReqiureComponent(SomeKindOfCollider)] and it will forcibly add one for you when you attach the script if the component is not found...
What doesn't change colour? I'm guessing there's some more code: edit your question, paste the code, highlight it and click the 101 button.
– whydoidoitHey there. The actual lettering of "OnTriggerEnter" within MonoDevelop doesn't change to orange/ blue or whatever the default is for MonoDevelop. I switched to Untron instead and it has been working fine.
– dcrispen014Sorry my bad I (clearly) am new here I'll try not to do that anymore. But thank you for the advice I did convert it to a rigidbody and that fixed everything. (sorry if that comes off sarcastic I tend to type that way but I appreciate all of your as well as everyone's help.)
– dcrispen014