- Home /
Instantiated Prefab doesn't appear?
So i'm trying to get it so the balls in my game spawn on their own, but they don't seem to be appearing at all. The Ball prefab has a script which makes it move to the left and control the player's movement if that makes any difference. It would work before when I was just testing the movement and interaction of the ball but now that I've used it as a prefab it doesn't seem to work.
I would suggest to start debugging this Start function to isolate the issue. Create Debug.Log outside the loop, inside the loop and inside if statement. This way you will understand where your code stops execution and how much time your loop executes. That will give you a hint.
Answer by misher · Feb 06, 2019 at 02:03 PM
According to your code you want to instantiate a ball in all points except a random one, I'm not sure if you really intended this behavior, in any case, you should have your balls instantiated unless you have the array of points empty (or 1)
Yeah I was sort of referencing another person's piece of code. The idea is to have 2 spawners, one for balls to hit and the other for balls that need to be dodged. So this way, it should randomly alternate between the two (Was just testing one type of ball for now).
Answer by kwaldow · Feb 06, 2019 at 02:00 PM
Hey, please make sure, that your GameObject you want to instantiate is markes as active. Sometimes while testing I deactiave the GameObject und then it is created without beeing active. You can also follow your objects: Select the object you want to follow in the hierarchy und press "F" continously. The Camera is following the gameObject. Please make sure you switch the scene view.
Yeah it's definitely active (assu$$anonymous$$g you mean the tick box next to the object name). But yeah, the problem is that it doesn't spawn at all, not that I can't see it. I know for a fact that it hasn't spawned since there are actions the player can only do if it the ball exists.
Answer by samisonkr · Apr 30, 2020 at 01:33 PM
Make the object is active, then drag it into a Prefabs folder. Then, set it active as you like. after that, drag from the Prefabs folder into the script of spawning.
It works for me.
Your answer
Follow this Question
Related Questions
Why is my Prefab Instantiating when the Scene is Loaded? 2 Answers
Having trouble with cloning with prefabs 1 Answer
How to move Instantiated 2D objects by 0.5 using arrows(or mouse) 1 Answer
How to instantiate a gameobject by aligning it to another one 2 Answers
Infinity runner - best way to spawn board in runtime. 0 Answers