Hi, everybody
I'm trying to make somthing really easy, but i'm stacked with a problem that i can't solve.
The code is very simple. I want to instantiate a particle system when a ball colides with certain objects. I did it before, but i can't see what is wrong in may code or in the rotation of the objects. The problem is that the instantiated particle system always point to the Z-axis.
Here is the code:
`#pragma strict
var impacto_enemigo_fx : GameObject;
var impacto_tierra_fx : GameObject;
var impacto_agua_fx : GameObject;
var impacto_metal_fx : GameObject;
function Awake () {
ignoreCollision("TORRETA");
}
function OnTriggerEnter(detectado:Collider){//si algo toca el collider comprueba si es "enemigo" y PUM
if (detectado.gameObject.tag =="TIERRA"){//el collider tiene que ser trigger
Instantiate(impacto_tierra_fx,transform.position,transform.rotation);
Destroy(gameObject);
}
if (detectado.gameObject.tag =="ENEMIGO"){//el collider tiene que ser trigger
Instantiate(impacto_enemigo_fx,transform.position,transform.rotation);
Destroy(gameObject);
}
if (detectado.gameObject.tag =="AGUA"){//el collider tiene que ser trigger
Instantiate(impacto_agua_fx,transform.position,transform.rotation);
Destroy(gameObject);
}
if (detectado.gameObject.tag =="METAL"){//el collider tiene que ser trigger
Instantiate(impacto_metal_fx,transform.position,transform.rotation);
Destroy(gameObject);
}
}
function ignoreCollision(tag : String) {
var objects = GameObject.FindGameObjectsWithTag(tag);
for (obj in objects) {
if (obj.GetComponent("Collider") && obj != gameObject){
Physics.IgnoreCollision(collider, obj.collider);
}
}
}
`
Thanks!
↧