- Home /
Realtime object loading to scene
Hello all! I'm very new to unity and programing and would like to learn. I'm working on a game that has lots of selecting from inventory.
For example:
GUI character selection. For example I press a button (label BOX) and a box with some animations pops into the scene. And if I dont like the BOX i press the button (label SPHERE) and a spining sphere replaces the box.
Now I understand I need an empty object in the scene where the objects are being loaded and displayed. I still dont know from where the object come from nor do I know how to write the scripts.
If anyone has any idea what I'm talking about and has any suggestions please help me!
Answer by programmrzinc · May 16, 2013 at 01:34 PM
What I am guessing is that you are trying to load objects during runtime. That is nearly impossible to do without Asset Bundles. What you can do is create a Prefab of both a Sphere and a Cube and then instantiate it like so. You can later make a gameobject active, or make it dissapear. Reply back and I can add a script with detailed instructions
Hi, thanks for the answer. Actualy making object invisible isn't the solution I had in $$anonymous$$d. What I need is more like a spawn point. When I select an object in the GUI-inventory that object shows in the viewport.
Another thing about the loading is.... When I select a character in the selection screen that character will be loaded in the level which too is being selected before you actualy start playing.
In short you get to a screen where you select a character and then you select a level (level has a starting spawn point where the selected character is loaded). Then the app loads the ID of the level (in this case a scene) and then the ID of the character (in this point I dont know what maybe a prefab). This is usualy made via database of somesort isn't it?
Add an empty gameobject where you awnt to spawn, and when you want to show the object, set the position to the empty GO's position.
For prefabs, you can just create different characters, and instantiate by the name
So you need to put every selectable object (character) into a scene if you want a selectable feature?
Can you tell me about asset bundles? If a get that plugin will it help me make this the way I want?
Your answer
Follow this Question
Related Questions
Saving character selection 1 Answer
Switching between multiple classes 2 Answers
Is it possible to keep the same Vector3 value using ScreenToWorldPoint with the camera moving? 0 Answers
How to make a character move towards a side of the screen that's pressed at a constant rate? 2 Answers
Camera doesnt follow selected character 0 Answers