Hi everybody, I am needing some help on how to instantiate an object(fire) on another object’s transform(tree), how do you call for another object’s transform to be the instantiating point in code?
Hi FatFoot,
So if I read your question properly, you would like to have some fire appear in your tree?
If it’s the case, is it the player that is “creating” the fire by shooting something on the tree? Can you give us some detail on how the fire get’s on the tree please?
Then, I will be in a position to help you.
I was using a particle system and for the collision I was using the world particle collider.
Ok I understand that but you haven’t answered my questions.
How is the fire to appear on the tree?
Does it appear automatically?
Does it appear after the player presses a trigger?
or
Does it appear when the player fires something on the tree?
In any case, you can start with this;
In C#
// GameObject go =(GameObject)Instantiate(GameObjectYouWantToCreate, Vector3 the position where you want it to appear);
GameObject go =(GameObject)Instantiate(GameObject.find("fire"), new Vector3(7.0f, 1.0f, 3.0f));
//if you want to tag it and give a specific name
go.name = "newName";
go.tag = "newTag";
In JavaScript
// GameObject go =(GameObject)Instantiate(GameObjectYouWantToCreate, Vector3 the position where you want it);
go : GameObject = Instantiate(GameObject.find("fire"), Vector3(7, 1, 3));
//if you want to tag it and give a specific name
go.name = "newName";
go.tag = "newTag";
The fire appears when the world particle collider hits the tree prefab collider. My teacher looked at it and typed in 2 lines of code and it fixed it, after that it worked, but I didn’t think about if the tree prefab is set on fire then set it on fire once, I added some code and fixed it to where if the tree prefab is on fire then set onFire to true. After that I quickly realized if the tree is on fire and onFire is true then I can’t set the other trees on fire, so that brings me to my next question, how do you make a clone of a prefab its own game object, or at least make it to where the item onFire = new object? Or something like that