- Home /
Question by
Griffo · Aug 05, 2012 at 07:39 AM ·
gameobjectcolliderboxcollider
Access other game object BoxCollider
Hi,
I'm trying to access an other game objects BoxCollider but can't get it right, can someone please tell me the right way, thank you.
#pragma strict
private var terrorist : GameObject; // Referance to the GameObject with the BoxCollider on it
private var boxCollider : BoxCollider;
function Awake(){
terrorist = GameObject.Find("Terrorist Body"); // Find the gameObject with the BoxCollider
}
function Start(){
boxCollider = terrorist.GetComponent(BoxCollider) as BoxCollider;
}
Comment
Best Answer
Answer by Griffo · Aug 05, 2012 at 07:52 AM
#pragma strict
private var terrorist : GameObject; // Referance to the GameObject with the BoxCollider on it
private var boxCollider : BoxCollider;
function Awake(){
terrorist = GameObject.Find("Terrorist Body"); // Find the gameObject with the BoxCollider
}
function Start(){
boxCollider = terrorist.GetComponent(BoxCollider) as BoxCollider;
}
Hi Griffo, How do I create a function similar to void OnCollisionEnter(Collision collision) for boxCollider when ever it collides with something? OnCollisionEnter(Collision collision) starts for the collision of the object itself, but I want a function that would enter when some other object hits a collision.
Your answer
Follow this Question
Related Questions
Tipping a cube over 2 Answers
C# Check If Gameobject is within Collider 1 Answer
How to check if a BoxCollider is hit by a trigger? 1 Answer
destroy gameobject when collider is fast enough? 2 Answers
Melee-like function? 1 Answer