- Home /
Particle system prefab not instantiated
I am trying to instantiate my fire particle system during runtime like this:
GameObject fire, firePrefab;
void Start()
{
...
firePrefab = Resources.Load("FirePrefab") as GameObject;
}
void FixedUpdate()
{
if (Input.GetKeyDown(KeyCode.V))
{
fire = Instantiate(firePrefab, transform.GetChild(3).position, transform.GetChild(3).rotation);
Destroy(fire, 5.0f);
}
}
My FirePrefab is just a regular particle system, and the model the above script is attached to looks like this:
Model
Default
Camera
DroneFire
However, my fire prefab isn't instantiated anywhere when I run the game.
Are you trying to get "DroneFire"? That is child number two, not three because the counting begins mostly from zero ins$$anonymous$$d of one.
Answer by Cuttlas-U · Sep 11, 2017 at 01:31 AM
hi; try this :
fire = Instantiate(firePrefab, transform.GetChild(3).position, transform.GetChild(3).rotation) as GameObject;
Your answer
Follow this Question
Related Questions
Prefab error while using Network.Instantiate 0 Answers
my prefab clone object are falling from ground in y direction? 0 Answers
How to manipulate a variable of a prefab script (instantiated) while the game is runnning . 1 Answer
Instantiated Projectiles doesn't go in correct direction! 1 Answer
Can't change change values of instantiated gameobject from another script 1 Answer