- Home /
Detection area
How do I detect if player is in specific area? Like transparent cube somewhere on the terrain and when player walks through it happens something.
Answer by You! · Jul 20, 2013 at 06:31 AM
The transparent cube idea is the right idea. Create a Gameobject with a cube collider (or any other type of collider), and set the collider as trigger. Then use the following example (in JS).
function OnTriggerEnter (object : Collider){
if(object.CompareTag("TagOfThePlayer")){
//add code for what is done when the player enters here...
}
}
This code, when added to the invisible cube collider (or whatever collider it happens to be), will activate an event or any other code (what you decide) when an object enters the collider and when that object has the tag of the main player object (check in the inspector).
Your answer
Follow this Question
Related Questions
Semitransparent GUI Buttons 3 Answers
How to make a GUI that isnt alpha transparent? 1 Answer
No transparency for EditorGUILayout.TextField 1 Answer
Transparent Textures 1 Answer
i can only see objects in game mode not edit mode, why? 0 Answers