Instantiate vs Enable/Disable VFX?

I remember in Realm Rush, Gary briefly explains the concept of Object Pooling. Is there a particular downside or upside to Instantiate the effect, rather than having it part of the Player prefab and simply use Play() on it?

Or are we going to refactor the effects in the future and use some sort of Object Pool?

I’ve added my LevelUp particle effect directly inside the Player prefab and unchecked “Play on Awake” this way I can simply call it with Play anytime I need it. I’ve also parented a Sword Slash that I can call when I attack with the sword. With this approach, you could also add some Trail effects for running and other things. Is there a downside to this?

We don’t really touch on Object Pooling in the RPG series, though there are a few places that Object Pooling could serve well (effects, and projectiles immediately come to mind). Since that concept is covered in some of our other courses, it wasn’t a high priority in a series of courses that is already packed with content.

That being said, attaching to the prefab is a perfectly appropriate method, especially if you make your particle systems in a way that they don’t rely on Looping (because then you can simply Play() when needed). In my own project, I have a Level Up, Respawn, and Heal Up particle all attached to the character. The downside is that technically, you may not need all of these particle systems, and they are loaded into memory when the game starts. On the other hand, a damage particle could have many many instances depending on combat, so pooling is a better option.

Thanks for the quick response, Brian! I watched Sam’s Video on Object Pooling yesterday ( from the new Game Patterns Course), and he mentions the same thing you did: disabled objects occupy memory as well. Glad to hear attaching effects to the prefab doesn’t have any other downside than that one.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms