Pending death or garbage pawn but I didn't ever destroy it

Hi,

Trying to create an array of “Pawns” for storage sake.

I have a BaseShip pawn, and have derived pawns for every type of pilotable ship in the game. My idea is once you switch ships, it’ll just switch the player pawn. Each ship has its own data such as stats and cargo

On game load I initialize a station’s ship storage to have one of the derived ships (testing cargo and inventory). This is a pawn array of type BP Base Ship.

Now later when I go access the inventory it says the pawn is pending kill or is garbage.

I never tried to destroy it. I did however specify “do not spawn” because I’d like it to just be data. Is there a reason this may be happening?

Is it impossible to set up pawns this way and should I handle it via another data container instead?

Thanks!

What do you mean “initialize a stations ship storage”?

Are you spawning the pawns? Is this an array of classes?

I may be wrong, but I think that if you do not spawn a pawn, an instance will not be created - i.e. it won’t exist. I don’t think you can just point to an object reference that was never spawned - it would be a reference to nothing.

Now don’t take my word 100% because I am not a real programmer, but I’d bet somebody $5 on it - I am pretty sure that’s how that works.

When you make a variable of your blueprint, notice that you are creating an object reference. I think that is the key word. There has to be an object to actually reference.

Well if that’s the case… it’s not necessary for actors.

This is actually exactly how I handle my items. Each item is an actor, when initializing an inventory I choose “Don’t spawn actor” and they all work.

The reason why I do this is some items are actors while some just exist as data.

Pawns may be different because they’re possessable… I’m not entirely sure though.

You cannot have an array of pointers to objects that don’t exist, so I’m not sure how you do it. If your pawn is a pawn that means it’s an actor, which means that it needs to have an instance and an outer object that is a world

Where exactly do you set the don’t spawn? In the collision handling?

If you are spawning the actors through C++, and you are using spawn actor deferred and never finishing the spawning, then I could see you being able to add them to an array, but maybe they would be considered garbage

Another thing, if you are doing it in C++, and you haven’t marked your array as a UPROPERTY, then its contents will not be tracked by the unreal reference system, so they could be garbage collected at any point

On another note, unless Items need to exist in a level, perhaps they shouldn’t be actors, but UObjects instead. They’re far more lightweight, and work great for data only items

This array of pawns. Did you have used the same setup on other objects? Or is just this one special case where you have an array of pawns?

Because I’m constantly struggling with unreal loops which will not wait for the loop step to complete and most of the time it will not create the stuff I’m trying to create.

So if you have used a loop to create the pawns, the pawns where not even created in the first place.

I don’t have a solution for this, actually I don’t understand why unreal loops don’t work properly. Is a mess

There’s nothing wrong with unreal loops really
But if you add a delay or a latent node after Loop Body, then that will never work, since the loop will not wait for the latent action to complete. Everything needs to happen in the same frame otherwise things will get overridden. If you want a loop with a delay then you could easily create it yourself in a macro library

Some items are considered as objects, others as actors. I’m not sure why it DOES work, but it does. As I set the actors to “not spawn”.

Why is that even an option? To just forcibly prevent the spawning?

Anyway the solution I came up with was to keep the “instanced versions” of each ship class in the storage, and create a pawn and possess the pawn when you choose the ship you want.