Basic Srcipting help in unity

Started by
10 comments, last by Eklipse 10 years, 2 months ago
OK, I see what's up. Your cube has the "Is Trigger" flag enabled.

http://docs.unity3d.com/Documentation/ScriptReference/Collider-isTrigger.html

IsTrigger changes the behavior of the collider in the following ways:

- It participates in collision detection, but doesn't participate in rigid-body physics. In other words, stuff can pass right through it.
- When another collider enters it, Unity calls OnTriggerEnter instead of OnCollisionEnter.
- When another collider exits it, you get OnTriggerExit instead of OnCollisionExit.
- You can use this to script things that happen when you move inside the trigger zone, like a proximity-sensitive door or a laser tripwire.

If you want it to act as a physical cube that you can collide with, just disable the IsTrigger flag. If you want to use it as a trigger zone, add OnTriggerEnter and OnTriggerExit methods.
Advertisement

Also i believe the enter is only called once, so if it enters but never leaves you won't get multiple calls. If you need to do something while the objects are colliding use OnTriggerStay or OnCollisionStay.

It sounds like your objects might be in contact the first frame and so its printing to the log. But since they don't move away no more enter events are generated.

This topic is closed to new replies.

Advertisement