- Home /
Instantiating a Particle system always facing Z-axis
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!
If i put this :
if (detectado.gameObject.tag =="TIERRA"){//el collider tiene que ser trigger
Instantiate(impacto_tierra_fx,transform.position,Quaternion(0,0,90,0));
Destroy(gameObject);
}
The instance rotates 180 degrees and not the 90 i put in there!!!!
What is happening???? I've tryed to change every axis and there is no way to the instance to point Up.
Hi, It is already set at 0,0,0 rotation in the prefab and the objects inside it. i don't know why, but i put a default particle emiter as prefab without changing anything and the same happends.
Answer by cdrandin · Apr 07, 2013 at 06:11 PM
Modify the prefab directly to point up and keep the rotation as all 0s. Which will create the prefab at the rotation it was created.
Your answer
![](https://koobas.hobune.stream/wayback/20220613095845im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Set parent of instantiated object. 0 Answers
How To: Spawn object on raycast collision. 2 Answers
Collision with tag 5 Answers
Issues with instantiated prefabs 1 Answer
Destroying a particle system assigned as an component? 0 Answers