hi,
does anybody of you know how I can do that if a gameobject (with a collider) hits an object it does something like this:
if(Robot.hit(this)){
blabla();
}
hi,
does anybody of you know how I can do that if a gameobject (with a collider) hits an object it does something like this:
if(Robot.hit(this)){
blabla();
}
Using Javascript you would do something like this:
function OnTriggerEnter(otherObject: Collider){
if(otherObject.gameObject.tag == “Robot”){
blabla();
}
You would also have to create a tag and name it Robot, then select that tag on the object you want to collide. Also you might have to set one of the 2 objects that are colliding to be the trigger.
This is easy, for more information visit this link:
http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html
Any questions, ask ;D
Hope this help
Collider enter:
function OnColliderEnter (hit : Collision) {
Destroy(hit.gameObject);
}
Trigger enter:
function OnTriggerEnter (hit : Collider) {
Destroy(hit.gameObject);
}