- Home /
How to instantiate a particle and make it play?
This is the code for explosion, im getting the following error: "BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Vector3)' was found."
I've been trying different things and i just cant get it to work.
function Explode(){
var self = gameObject;
destroyedpos = transform.position;
var explosionparticle = Instantiate(self, destroyedpos, Vector3.zero);
explosionparticle.Play();
}
Answer by _1 · May 11, 2014 at 11:45 PM
In the third parameter of Instantiate its supposed to be a quaternion not a vector3, a quaternion is basically rotation if you don't know what a quaternion is, just do Instantiate(self, destroyedpos, Quaternion.identity); this will make it spawn at the same rotation as the gameObject your script is attached to
Your answer
Follow this Question
Related Questions
Explosion at mouse 1 Answer
Rocket Launcher explosion 1 Answer
Particle System Instantiate's With Original Rotation - C# 1 Answer
Calling a variable 2 Answers
Spawn Explosions Horizontally 1 Answer