- Home /
Make objects spawn
Hello. Im kinda new to unity an have a problem.I want to make an object to be disabled in the start of the scene, but when i collect an item, i want it to be activated.I already tried the rendere.disabled method, but it only makes the object invisible, and i want it to be completely inactive. anyone can help me in this one? Cheers.
Answer by joedrigon · Sep 19, 2010 at 08:24 PM
Well what you can do is create a prefab of the object you want and not put it into your scene. Then, once you collect the item you need just use Instantiate to create the object.
Is that what you are trying to say? If not let me know...
Yes, that worked.Just one more question: do I need to use transform.position = Vector3(x,y,z) to set its position? Cause when I try the position gets all messed up. Thanks!
Answer by joedrigon · Sep 19, 2010 at 09:01 PM
Yes, you will need to set:
Instantiate (prefab, position(a vector3) rotation(a quaternion)
example
Instantiate(PrefabName, Vector3(5,5,0), Quaternion.identity);
more info here
Your answer
Follow this Question
Related Questions
Configure rendering distance 0 Answers
I need To spawn game objects randomly, but I'm Getting an error in My script, Please help! 1 Answer
Spawn Random Objects on a Sphere Surface 0 Answers
NetworkServer method to spawn map objects (once in a match) 0 Answers
NullReferenceException: Instatiate with construtor OR in Inspector 1 Answer