[Plugin] Object Pool Component

@LatFoued I’d suggest you take a look at your Blueprint Graphs and make sure you don’t have “Spawn from Pool” nodes with unlinked Pool pins as well.

If you believe there’s something wrong with this warning, you can double-check the code.
This warning comes from this file:

K2Node_SpawnActorFromPool.cpp:



    const TArray<UEdGraphPin*>* PinsToSearch = InPinsToSearch ? InPinsToSearch : &Pins;
    //
    UEdGraphPin* PoolPin = GetPoolPin(PinsToSearch);
    UClass* SpawnClass = nullptr;
    //
    if (PoolPin && (PoolPin->LinkedTo.Num()>0)) {
        auto LinkedPin = PoolPin->LinkedTo[0];
        UClass* PoolClass = (LinkedPin) ? Cast<UClass>(LinkedPin->PinType.PinSubCategoryObject.Get()) : nullptr;
        UObjectPool* PoolComponent = Cast<UObjectPool>(PoolClass->ClassDefaultObject);
        if (PoolComponent) {
            SpawnClass = PoolComponent->TemplateClass;
        } else {
            UE_LOG(LogTemp,Warning,TEXT("{Pool}:: %s"),TEXT("Trying to Parse Object-Pool Component, but Pool Component is Invalid!"));
        }
    } return SpawnClass;


You can see there the errors shows up because for some reason your Pool Component came out as a nullptr.
Maybe this node is executing in your Blueprints before the engine has generated PoolClass’s “Default Object”.

I see, I’m currently debugging the project using packaged builds in development. It feels like it is because of the way I have it setup and not from the Plugin, which is nice as I can debug my own code better :slight_smile:

I’ll let you know when I come to the conclusion. But, for that invalid component error, it actually was when I started packaging, no ingame.

WHEN I DO Nativization MY BLUEPRINT PROJECT TO C++ PACKAGING THIS ERRORS OCCURED , HOW DO I SOLVE THIS ISSUES? ANY IDEAS?

@ I have never in my life used Blueprint Nativization, sorry.

Many devs have implemented nativization themselves, but I have never used it, so I have no idea why nativization causes that.
I think you could try to disable it for the plugin instead; since the plugin is already running on C++ there’s really no reason to “nativize” this. It is already native C++ code.

For a heads up on the issue I was having with the Packaged project not working properly, it basically was UE not properly saving my Object-Pool project settings. I need “Instantiate on Demand” for my project to work and the default is “False”, but in project settings I set it to “True” and all works fine, but after packaging, it acts as if it isn’t working.

So what I did is simply add the default values I needed to the Config/DefaultGame.ini


[/Script/OBJPool.PoolSettings]
ReinitializeInstances=True
InstantiateOnDemand=True
NeverFailDeferredSpawn=False
KeepOrphanActorsAlive=False

Update for Unreal 4.20 submitted to Marketplace for review.

Hey , everyone.

Just brought and implemented the object pooling plugin and its working great, I’m creating an endless runner for mobile and after a lot of testing / figuring out performance bugs, I’ve finally cracked it. The game runs well, 120fps on my Mac and 35 fps on my android, no performance lags, just continuous frame rate, the pooling has given me that so thanks sooo much!

but

Im having trouble with my respawned coins. I’m finding that if I have hit them before or if they are picked up by a magnet kinda thing, that when they are respawned next time, they keep those magnetized settings, or they won’t get picked up before because they have already been picked up on the last spawn.

I guess whats happening is that when a coin is sent back to the pool, it is not being told to revert back to its original coin state, its being kept in ‘magnet state’ and flying from its spawn point in the distance to the player.

Is there a way to reset the coin to its original settings/state on return to pool, or a setting / checkbox that I’ve overlooked? I’m only about a month or so into learning unreal so yea a bit of a noob.

any help is much appreciated,

cheers
a

You will have to tell your pooled class to reset its properties on either one of these Events:

Right, makes sense. How are you getting those nodes? what do I right click and type to get them, or are they pulled in from variables?

All Blueprints children of PooledActor have them;
Right click graph and search below “Add Event” context menu category.

ahh, yep I have the event nodes, I mean the ‘set initial speed’ ‘set max speed’ nodes. Are you setting them from the float variable (green Bullet speed) , if so how do I get access to the target option.? or are you right clicking and calling something?

They aren’t relevant to your issue.
It’s just an example, just the red nodes matter there…
You just need to reset your magnet properties from one of those Events like the example image.

Fixed, I had marked a coin as used and that was getting carried into the pool and still active on respawn… rookie mistake :slight_smile: Cheers for the help , plugin is magic!

Update for Unreal 4.20 released.

Thanks for a quick update! :slight_smile:

I’m wondering if it would be useful to add native events do PooledActor (and similar classes) on begin/end play.
We already BlueprintImplementableEvent (EVENT_OnPoolBeginPlay, EVENT_OnPoolEndPlay) and delegate (OnPoolBeginPlay, OnPoolEndPlay).

In my project I extend PooledActor class in C++, so native events come handy.
Of course, it’s not a big deal. I used to add few lines for it after every update :wink:

[USER=“69”]Cheshire Dev[/USER] you mean “BlueprintNativeEvent” or do you mean pure cpp delegates?

I mean BlueprintNativeEvent :slight_smile:

Hey , I’m running 4.20.1 and either I am overthinking the entire process, or I really can’t understand your guide for implementing this plugin using blueprints. I have a gun and I want it to shoot pooled bullets using your method. I won’t go into detail for all the different ways I have attempted to solve this but I can assure you I’ve managed to crash my engine in at least 5 different ways. I understand I need to create an ObjectPoolComponent then I need to reparent my BulletProjectileBP to “PoolActor”. This is all I KNOW how to do. Now I am not sure where to put the component…

If I put it in my gun my game crashes on simulation… if I try putting it in an empty actor… it crashes as well. I’m at a loss for what to do. If you could help me understand this process I will gladly re-write your instructions so you can post it as an addendum (or preferably a replacement) to your guide… English is my native language and I am really clear with written directions… Thanks.

Some times ppl attach Pool Components to Pooled Actor and that causes crash (loop).

Without crash logs I cannot know why your project crashed.
Optimal report would be:

  1. You run Unreal Editor launched from within Visual Studio (VS will tell you why and where the crash happens, which line and from which function)

  2. Unreal generates crash report logs, you send me the latest log so I can read it.

  3. An isolated project reproducing the crash I can use to fix it in case of bug.

But up to now, as said above, some people are causing loops attaching Pool Components to Pooled Actors, it’s the only crash I know of right now.

Hello, I set “PooledProjectile” component instead of “Projectile Movement” component to my bullets.
I set initial speed and activate them on pool begin play. But bullets with pooled projectile did not moved. How did I set something wrong ?
This project is in Unreal Engine 4.20.1