[Plugin] Object Pool Component

Now it’s falling to the ground, even if it is not breaking up everything…

Tell me, what you have fixed to use your implementation, or is anybody of help to get my projectile up running ???

Setup your physics channels correctly.
Your bullets are just hitting each other in the pool, you should make them ignore their own collision channel.

This doesn’t make my MovementComponent work !
They are spawning correctly, but then just drop to the ground and after hitting the ground returning to the pool.

Looking into the demo project might help.
There’s something in your blueprints you’re missing.
Maybe try to disable their gravity until the projectile leaves its owner?

Also check velocity (direction) vector.
It shouldn’t be a 0,0,0 vector…

BLT->ProjectileMovementComponent->SetVelocityInLocalSpace(FORWARDVECTOR * LaunchSpeed);

I am not moving it with blueprint, nor changing settings in blueprint !

Another thing, i don’t get is, how to choose which object i wanted to take away from a shared pool.
How would i say, i now want to spawn an object placed in the second array slot for pooled actors ?
I have that information, that i wanted to do it, but i don’t know, how to ask the shared pool for it.
I found :
static APooledActor* BeginDeferredSpawnFromPool(const UObject* WorldContextObject, USharedObjectPool* SharedPool, UClass* Class, const FPoolSpawnOptions &SpawnOptions, const FTransform &SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride, AActor* Owner, const bool Reconstruct, bool &SpawnSuccessful);

But which UClass Pointer should be inserted there ?
In both cases there are the same classes in, with completely different value settings.

If second array is, say, “ABlueBullet”…
On UClass* param for spawn function input ABlueBullet::StaticClass()

All three classes are APooledExplosion with ParticleEffect and Soundcue Playsettings
I have worked around this by setting up three values to identify my blueprint

UPROPERTY(EditDefaultsOnly, Category = “Setup”)
UClass* Cannon;

UPROPERTY(EditDefaultsOnly, Category = “Setup”)
UClass* Gun;

UPROPERTY(EditDefaultsOnly, Category = “Setup”)
UClass* Missile;

UClass* currentClass = nullptr;

if (CannonType == 0)
currentClass = Cannon;
if (CannonType == 1)
currentClass = Gun;
if (CannonType == 2)
currentClass = Missile;

If i would insert just APooledExplosion, this doesn’t help.
Isn’t there a possibility to just grab 0 ?

Btw.: My MovementProblem still is unsolved !
Working with your class and PooledProjectile worked quite fine, except the little thing about crashing my editor.

If you have a workaround for me, i really would like to take away the PooledProjectile case, but i don’t know how to fix that now, your small comment did not lead me.
Right now everything just pees out of my muzzle and falls to the ground, because physics are active.

Look at MovementComponent source.
It needs a valid velocity vector to move or it won’t gain speed from Tick.
Since you are doing things in C++ I have no idea what you’re missing.

It looks like everything is set, all velocities match, but my static mesh component isn’t influenced by it in any case …
In the blueprint, it flies away, but it doesn’t after spawning …
And you have seen all code, which is first based on your sample and a projectile, that did fly without object pool.

I think someone around page 5 to 7 in this forum topic had same problem as you.
But I don’t remember if he explained what was bugging his setup, maybe wrong physics settings or he wasn’t calling Super::PoolBeginPlay on his Blueprints, I’m not sure.


By the way, are you sure you are executing *APooledActor::FinishSpawnFromPool(…) * after you spawn your PooledActor from C++ with APooledActor::SpawnFromPool(…) ??

After calling *BeginDeferredSpawnFromPool(…) * you have to call *FinishDeferredSpawnFromPool(…) *to complete the routine otherwise everything bugs out.

This is quite funny - and i don’t know the answer !!!
I worked it back, changing your demo class to the same, just letting out the PooledProjectile.
Then i added the PooledProjectile to the blueprint, and worked in the setup with the construction script and added the functionality to the two events Shoot and Break.
Somehow this works, and no longer breaks everything.
And i am fine with that - really.
Projectiles fly around, i did not want more from that ! :wink:

Hmm… Sometimes when you recompile component code, Unreal will bug delegates; then you have to remove and attach again the Component you’ve changed source or delegates will remain broken for that Blueprint.


I’m moving delegates setup to PostInitProperties() on next update, that should help making sure this weirdness won’t happen again.

Nono,
This is originated on your demo project for 4.20.

It works fine, and doesn’t have problems.
And you put in there C++ classes for an Actor Pool and a Pooled Actor with Pooled Project, which also looks quite good.
But you aren’t using it !
Your blueprint examples work fine, but they don’t use your C++ demo sources.

Whenever you try to make Blueprints out of them, the Projectile will break after a while, at least, when restarting the project, but somehow this happens after a time, so you don’t really know in the beginning, that there is something going on.
What you see very fast, that you cannot build the project any longer, if there is a c++ based blueprint in there.

You can try yourself with your demo, maybe you find out what really is going on.

It’s not, that i am doing fancy stuff, nor change too much.
If i am missing, calling Super somewhere, it is missing from the beginning, and i don’t see it yet.

The change mentioned above is published on Marketplace now, for both UE4.20 and UE4.21.

Sorry for being so unclear for you and thank you !

Just to give a Show…
Your pool is awesome !

Any projectile in here (5000) and Explosion, like HitExplosion or Muzzleshot is Pooled by your Object Pool with the C++ implementation, that you have given me/us.
And i don’t own the ultimate PC, i “just” own a 4 years old i5 with a GTX 970

I got the same glitch mentioned on comment #149. ([Plugin] Object Pool Component - Marketplace - Epic Developer Community Forums ) The editor crash when I delete “Spawn Actor From Pool” node.

I deleted all other nodes which are connected to Spawn Actor From Pool node. But the editor still crashes.
I create another nodes of “Spawn Actor From Pool”. When I connect a pool component to this node, the editor crashes.

Can you launch the Editor from within Visual Studio, and see if the crash gives a trace?
Also, collapse the node to a sub graph and delete the graph, see if that helps.


There are too many reports of Editor crashing when deleting (any type of) nodes.
So I have to make sure this is caused by me and not some random Editor bug; so far I have never managed to crash UEditor when I delete any nodes.

@skydashstudio Watching the video again… I see that you did “Split Struct Pin” on the “Spawn Options” struct pin.
However, the plugin expects that struct pin to exist on the node, it must find that struct pin in order to work properly… this might be related to the crash you got there with that node.

I have submitted an update for UE4.20 and 4.21, trying to prevent that from happening.
Still, I’m in the dark about that crash, I need a way to reproduce it here, up to now I simply can’t see that crash happening anywhere.