Spawning Actors in UE... It's complicated.

preview_player
Показать описание

0:00 Intro
2:57 Object Pooling
6:51 Data-Oriented Design
9:43 Niagara Projectiles
12:12 Niagara Impacts
13:22 Outro

Hey! Quick video to mention different methods, all widely used in the video game industry, to spawn & render lots of actors/objects and how to (inefficiently) implement them in Blueprints. I hope you'll like it. Cheers!
Рекомендации по теме
Комментарии
Автор

Just a suggestion: any pool manager should be a template based, meaning it should be able to create a pool of any type of objects/actors, so that it could be reused in many different cases. 'Template' in case of BP is called a 'Wildcard'. I'm not sure though if you can pass a wildcard to the spawn function directly or though a cast, but in C++ it's easy to make this happen: you make a wrapper function for spawning that takes an instance of a template class, check if that instance is an actor and then call the Unreal's Spawn function.

scrappyd
Автор

00:32 im not even 1 minute into the video and bro already roasted the fk outta me 💀this is what u need to keep on learning (banger vid as always 🔥)

thCrusade
Автор

There are probably a few tricks that can further reduce overhead. As an example, if you have a pool per actor that can fire projectiles, you should also know fire rate and lifetime of the projectile. Therefore, the array should never need to be larger than ceiling((projectiles per second) * (lifetime in seconds)). That way, you're not reserving memory you're never going to need, and should avoid the need to resize the array unless fire rate or lifetime changes.

There's also a slight optimization in picking the first available projectile. Because of the way your approach and my thoughts on an optimization are structured, every tick has to check the entire array to decide for each item if collusion checks need to be run; there's no guarantee that you've found the last active item in the array without doing some kind of check/store elsewhere. As such, you can optimizing finding an inactive projectile by storing the index of the last projectile made active and starting your search from there. The next index should always be available, unless we're at the end of the array, in which case the 0th index should be available if the array is appropriately sized to fire rate and lifetime. This results in similar best case, slightly improved average case, and a much improved worst case.

alexanderjordan
Автор

Excellent video! I'm currently in the trenches of data-oriented designing as well!

In my last try at implementing a pool I ended up using a set of active and a set of used ones. And instead of querying the object for if it was being used, I did a Intersection. The idea was supposed to minimize the amount of times we access the object itself to check it's state. But then ofc you pay the price of managing two sets.

Mireneye
Автор

A very interesting example of object pooling in Unreal

faimenDev
Автор

Wherr are you Ghislain?? We are addicted to your videos, lots of people are having withdrawal effects 😅 come on man, we need new of your brilliant tutorials!!

Bdkdmnso
Автор

Hi I love your videos and wanted to make another suggestion! Instead of having a boolean to check if a projectile is in use, you could have two arrays to hold your used and unused projectiles.

That way you avoid having to allocate extra memory into the struct, inefficient memory alignment, and it could be more ergonomic for the develop to pull things from an array instead of always checking a boolean.

Thanks for your video, loved it.

ramontovar
Автор

Super useful! As for performance, have you tried the profiling tools? Maybe you have and I forgot. "session frontend" (in UE4) You can see the ms cost of an actor down to literarily the individual BP nodes. Not sure though, might also be some ethereal overhead, so you might be right it's hard to know.

ViktorartSnowtracked
Автор

As someone else who is self-taught and continuing to learn, would it make sense to destroy / generate new pools when a weapon is switched based on that weapon's clip size?

MrPentagear
Автор

What about replication? Would it be possible/efficient with this method and niagara projectiles?

UTSIDER
Автор

Can you make a fluid ninja series to make a multi-biome landscape auto material with it pleaseee!!!!

davy
Автор

You’re only highlighting the “plus” side of object pooling. How about describing the negative side of this? Like always having everything loaded into memory. This is such an old design terminology that would be nice for games in 70’s but can’t imagine it still being useful for modern day game design where we try to load and unload everything constantly because of hardware limitations (we build and design games for consoles, not the 1% of consumers with a rtx4090 / 64GB+ ram and a 32 core cpu) also you talk about the garbage collector like it’s a bad thing………

KillerSneak
join shbcf.ru