how can I do it that if something hits something it does something?
for example:
if(Robot.hit(this)){
blabla();
}
how can I do it that if something hits something it does something?
for example:
if(Robot.hit(this)){
blabla();
}
function OnCollisionEnter(hit : Collision)
{
if(hit.gameObject)
{
blabla();
}
}
Hey there,
Take a look into the Unity Script Reference. There are 6 functions for collision detection.
OnTriggerEnter
OnTriggerStay
OnTriggerExit
OnCollisionEnter
OnCollisionStay
OnCollisionExit
They're used like this:
void OnTriggerEnter(Collider other){ //the collider other collides with assigned object
do this
}
Be aware you need to attach colliders,triggers and rigidbodys for your collisions to occur
Here’s a link to the reference: http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=collision
also you can check the manual about Rigidbodies. There’s some useful information in there
regards
and how can I do it that it does something when it hits anything?
(I wrote a comment but nobody answered so sorry for this “answer”.)