I understand the concept and implementation of an Object Pooling System. I want to make an after image speed effect, and I've watched a video on how to do this. however, this tutorial uses instantiate and destroy, which seems inefficient. However, using this system, won't the baked meshes from the previous instance just end up in memory limbo when replaced by the next set of data? How would I sort this out? if it's an issue at all, I might be overthinking it after all
#Object Pooling System for an After Image effect
1 messages · Page 1 of 1 (latest)
In this video, the guy bakes skinnedmeshrenderers into standard meshes for use by a standard mesh renderer
https://www.youtube.com/watch?v=7vvycc2iX6E&t=400s
With this Unity tutorial now you can add a cool Trail to your Characters! Super useful for when trying to convey a speed boost or a quick character movement, like a dash. I am speed!!!
I am making a game, check it out: https://twitter.com/GoldenBugStudio
00:00 Intro
00:51 Mesh Trail Script - Start
04:54 Baking the Mesh
08:05 Glow Shader
10:2...
this is the code for context
you can use object pooling for this no problem.
You can pool both the GameObejcts and the Meshes
Notice that BakeMesh overwrites an existing mesh: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/SkinnedMeshRenderer.BakeMesh.html
so at the start i could make like, 100 gameobjects with mesh renderers for example
and enable and disable and overwrite the meshes
there's no need to make anything at the start
as needed
isnt that how pooling works? i might be mistaken
Use Unity's ObjectPool implementation: https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Pool.ObjectPool_1.html
ObjectPooling is not about when to create the objects
it's about when to destroy them
instead of destroying them you put them back in the pool to be reused
oh right
but there's no reason to "pre-cook" the pool most of the time
i thought part of the pool system would be to create a bunch of them at the start
okay thats fine then
i didnt know that api existed
thats cool
makes it easy for me
Unless creating the objects is prohibitively costly, there's not much benefit to that.
It's more about avoiding the overhead of garbage collection
you're only creating at most a few each frame here.
so when you overwrite the mesh, the old mesh disappears? is that garbage collected?
it doesn't disappear
you're just changing the data
you're modifying a mesh in place, instead of discarding an old one and creating a new one
that's what you avoid with the pooling
i get it now
cool, thank you!
that object pool thing looks exactly what i need
If this is a single character, you can just make a bunch of children of these skinmeshes. You don't exactly need a whole management system for it.