hi guys I’m just wondering is there a limit to Objects you can include in the Object Pool? I just had this recurring problem wherein whenever I add a new object in the Object Pool, Unity crashes so I had to END it in the task manager or maybe I was coding it bad.
Hmmm how many objects are you trying to pool?
And how are you doing it all?
For me I just use a for loop and instantiate at the start so I don’t have to manually do it.
E.G.
public GameObject obj;
List<GameObject> poolList = new List<GameObject>();
void Start(){
for(int i = 0; i < 25000; i++){
GameObject poolObj = new GameObject(obj, Vector3.zero, Quaternion.identity);
poolList.Add(poolObj);
}
}
I was actually hoping to get this scene working, I have a hammer hitting a button then different sort of explosions get instantiated using the object pool I just dont know how to make it work, Ive been doing this for just a month so lots of things still doesn’t quite make sense to me lol
Im trying to do it with object pool and switch method
General discussion is not a support forum. Please honor the forum rules if you want our help.
Please do not screenshot your code. Use the code tags to include your code properly.
You did not show us where do you add a new object to the pool? (Code tags please)
Do you get any errors in the console? What are they?
Have you tried to locate which line Unity crashes on? And have you checked the editor logs?
You have an inescapable loop condition in your code.
I imagine.
You didn’t show us any relevant code.
Sounds like it though.
this is so frustrating I just cant make it work…I get to spawn an explosion but only once and one type of it when it is supposed to be random of different type of explosions …I was able to do this with the basic methods but pooling seems to be too much for my brain capacity even though I did enough research
how can hitting a button with a hammer to trigger different types of explosions prove to be so difficult ![]()
There is a button on your computer called “Power”, hit it, stand up and go for a walk or something. You can’t learn while you’re frustrated. When you’re cooled down, read this thread again.
Easy:
void OnButtonPress()
{
while(true)
{
Debug.Log("You better have that taskmanager ready, cause I ain't going anywhere");
}
}
Take a break, come back to this with a clear head. Go through all the loops in relevant code and add Debug.Log statements. You almost certainly have an infinite loop somewhere.
