- Home /
Prefab instead of class oClass = new class() ?
Hey, in some javascript - canvas game engine when wanted to create a bullet object I simply did: class oClass = new class(). Can I do it in unity as I wrote ? Or to make a new object I need to have a prefab and then I create instances of it when I want to shoot ?
Answer by Landern · Mar 18, 2015 at 04:21 PM
If i understand your question correctly.
It's a good idea to attach a gameobject/transform to a script variable of the same type. This would be your prefab.
You would instantiate the prefab as the bullet. Later if performance is an issue and depending on how you want to use it, you may want to use a objectpool system. You can look these things up on google and find a ton of examples and code.
Your answer
Follow this Question
Related Questions
Instantiate object 1 Answer
Prefab instantiated wrong scale on mobile 0 Answers
autolink to prefab? 0 Answers
Inconsistent OnMouseEnter caused by Instantiate 2 Answers
Add 0.5f to Vector.Right on next instantiated object ? 1 Answer