Unity Spain
Post Antiguos => General (Antiguo) => Mensaje iniciado por: Gastonspas en Agosto 04, 2017, 05:39:31 AM
Hola gente disculpen las molestias pero quisiera saber por que no dectecta la collision de cada objecto dejo un video para mostrar mejor
eature=oembed" width="480">
function OnTriggerEnter(other : Collider)
{
if (other.gameObject.tag == "ru_men_die")
{
cualsera = 1;
Debug.Log(cualsera);
}
if (other.gameObject.tag == "ru_mas_die")
{
cualsera = ;
Debug.Log(cualsera);
}
if (other.gameObject.tag == "ru_x2")
{
cualsera = 2;
Debug.Log(cualsera);
}
if (other.gameObject.tag == "ru_balas")
{
cualsera = 3;
Debug.Log(cualsera);
}
if (other.gameObject.tag == "Player")
{
cualsera = 4;
Debug.Log(cualsera);
}
}
La deteccion de colision se da entre objetos especificos, existe la famosa tabla en las referencias que te dice que objeto con que esta habilitado, ponele al objeto trigger movil (o a uno de los dos, o a todos los cuerpos) un rigidbody (kinematico) y deberia imprimir correctamente, pero te recomiendo revisar la tabla que mencioné tu caso seria collider vs rigidbody, fijate que collider vs collider no existe creo.
te falta agregarle un rigidbody junto con el collider:
"Notes: Trigger events are only sent if one of the Colliders also has a Rigidbody attached."
( https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html (https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html) )
mirate: https://unity3d.com/es/learn/tutorials/topics/physics/detecting-collisions-oncollisionenter (https://unity3d.com/es/learn/tutorials/topics/physics/detecting-collisions-oncollisionenter)