I am newbie in unity3d, I just want to make a square area which will should be transparent and when a object enter into that square area or touch that area then I should let know that some object enter or touch area. Kindly let me know or suggest me how can i do this task. This will be great for me. Thanks in advance.
What you want is a GameObject with a collider marked as “trigger” and a script reacting to the OnTriggerEnter event.
Here’s how you can do it :
- Create an empty GameObject
- Add the component Physics/Box Collider to the object (other shapes are ok too)
- Tick the option “Is Trigger” in the box collider properties
- Create a script for this gameObject
- Add the functions OnTriggerEnter, OnTriggerStay, OnTriggerExit to your script. And do whatever you want to happen in them.
documentation for OnTriggerEnter
documentation for OnTriggerStay
documentation for OnTriggerExit
Make a cube, delete the Mesh Renderer, add a collider and make it a trigger.
Now you can attach a script onto the object with
void OnTriggerEnter() {
AlertOtherObject()
}
or if you use UnityScript
function OnTriggerEnter() {
AlertOtherObject();
}
Check this page for more info
make a cube or plane or whatever shape via
GameObject->Create Other->Cube
put it where you want it and go into the inspector and click “Is Trigger”… this will make the box so you can walk through it
then remove the mesh renderer component and it will be invisible
you can then refer to the name of your Cube in a script to trigger events
then click the