[Plugin] Object Pool Component

Is PooledProjectile Component works for Pooled Pawn ?
I made a missile as a PooledPawn instead of PooledActor because I want it has Hp, player can shoot them down. And make it is a child class of my “EnemyPawnBase”.

I use PooledProjectile in Pooled Actor. It works well. But it does not works in PooledPawn.

No, only if a few C++ lines of code are charged :slight_smile:
Some people do it themselves, but I will take note and add this change when I can.

@skydashstudio I submitted today an update for Unreal 4.20 where Pooled Projectiles shall support Pooled Pawns (without additional code needed);
In few days EpicGames should release it to Marketplace.

After I updated plug-in. Pooled Projectile works on my Pooled Pawn. Thank you.

I have tested my game again. Then I noticed something strange. I recorded a demonstration video.

Function “Deactivate” does not works on Pooled Projectile component.

When I use function “Deactivate” to normal projectile movement component, they stop moving.

But when I use function “Deactivate” to Pooled Projectile component, they still moving.
I use function “Set Direction” to x=0 y=0 z=0 too, But they do not stop moving.

I also cannot use function “Set velocity” in Pooled Projectile as I use in Projectile Movement component.

Did you try to get the “native” Movement Component from Pooled Projectile and deactivate it?
There’s a node on Pooled Projectile to get the native Component instance from Pooled.

Thank you for advise, I found a function “Get Projectile Movement Component” from Pooled Projectile.
Then I can deactivate them. I can also set its velocity as I do for unpooled actors.

Great to know it worked! :slight_smile:

Wait for Unreal 4.21 compatible.

I will install 4.21 tomorrow at home and will begin porting plugins this weekend.

I have big problems in writing C++ Code.
Even if i take away your Code from the plugin as it is:

After i create a Blueprint for my Pool and Projectile C++ class, i cannot build my project anymore, and - after restarting the IDE the blueprints are broken.
In fact, it’s the Pooled Projectile code, that is broken, and breaks everything, that’s attached to it, so if it is used in a pool, it crashes the pool too, and if this pool is used on a map, the whole map is broken and everything must be deleted, before i can restart my ide in any way:

The only thing i changed is making the Static Mesh being possible to modify…

What’s happening ??

Btw. i see, this is happening with your original C++ Code, too, that’s really bad, because it makes me changing a complete concept out of C++ to Blueprint and back to C++ which is really unhandy !!
So, what’s happening here ?

If i take away the original Pool project, make a blueprint out of PlayerBulletRank3, close the project, reopen it, the blueprint is broken, and everything using it is broken, as i said before.
I cannot build my project any more, and it destroys about everything, where an object pool might sit, using this Blueprint class…

That Component can ONLY be attached to a APooledActor or APooledPawn.
You are adding PooledProjectile to something that cannot support it.

​​​​​Anyway, I will move that setup to PostInitProps to avoid this problem.

Hi , I am looking for clarification if possible,
I see that pawns and actors once drawn from the pool have physics etc woarking as normal.

I have a railway simulator that can up to 100 wagons of any one type, these wagons work purely by physics/ collision they are guided along the track and pushed / pulled with no coding.
Would this plugin be suitable ? or is it suitable for projectiles only ?
each wagon is a skeletal mesh+ physics asset at the moment they are pawns to enable operations to be carried out on the wagon easily… ie loading, coupling applying brake etc.
but they could be actors if necessary.

At present a train of approx 30 wagons gives me a hit of around 12-15 fps nearly all of which is physics doing its thing

Your views appreciated

Thanks
Paul_G

@**Sly401 **Any Actor/Pawn/Character can be turned into pooled ones (just re-parent them to equivalent Pooled parent class).
The Pooled Projectile is just an extended Component to make bullets work with pooled classes; it isn’t required to be used.

But I’m not sure what you want to accomplish, are you constantly spawning and destroying wagon cars?
If you don’t have to spawn/destroy them constantly, using pooling system won’t help you there to save performance.

Hi ,
I do spawn cars 25-30 at a time and when they have completed the run they are destroyed, however it seems that you are saying the plug in saves performance during the spawn operation not during the running, in which case the plugin will not help,
I have no slow downs or difficulty in spawning / destroying as they spawn out of site/gameplay area at 1sec intervals to make up the train.
Sorry if I grabbed the wrong end of the stick I was unsure if the pool object offered any phys performance benefits…(why I asked for clarification)
THanks
Paul_G

If you’re spawning ~30 cars every second then yes, the plugin will definitely help with performance.
Will always be better to spawn the wagons from the Pool than delete/re-create them in such a short period of time.

I was just using your example code, so please fix this for all of us in the future yourself, too !
It wasn’t my idea to do it this way, i saw your code and changed it !

And yes ! This really fixes the issue !
So i just have to implement my old bullet again, that’s quite fine

Next update shall prevent that from happening.
I removed that function from Post Load.

Another thing, i cannot do, is, when having a blueprint from my C++ class, setting up the value for LifeSpanPool leads to crashing the system.
I implemented my own TimerDelay this way, which is working handy:



    UPROPERTY(EditDefaultsOnly, Category = "Setup")
    float ReturnDelay = 5.f;

    UFUNCTION()
    void OnTimerExpire();

Inside Shoot_Implementation:
    if (ReturnDelay != 0.0f)
    {
        FTimerHandle Timer;
        GetWorld()->GetTimerManager().SetTimer(Timer, this, &APooledCannonProjectile::OnTimerExpire, ReturnDelay, false);
    }

void APooledCannonProjectile::OnTimerExpire()
{
    ReturnToPool();
}