Remove/Destroy picked up objects

Hello! i have a problem and i could not understand nor how to solve it.
if this is solved in another post i would like to take a look so i can remove mine.

i have 3 shields Front, left, Right.

the character can pick all of them or any of them.

the issue is when the character pick any of them then picked another one of the same type it will stack on top of each other, for example:

the character picked Front shield then picked another Front shield there will be 2 shields on top of each other : see photo

Screenshot_3

this photo if the character picked the same type twice:

Screenshot_4

what i want is to destroy the old shield when character pick up the new one of the same type.

here is my blueprints for the shields

  1. is a base blueprint for the shields ( i made 3 child from it )

and this is what inside of it

2, is the spawn able base blueprint ( also made 3 child of it )

and this what inside it


1 Like

Perhaps there’s no need to add a new component. Use the existing CAC and set a new shield class. This would destroy the existing shield actor and replace it with a new instance:

image

thanks for replaying! but where should i do that? here?

can you please help me out here, I’m fairly new to blueprints and all

1 Like

Where is the bit of script responsible for picking up the shield? This says weapon, I don’t know the system you have so a bit lost here. :smiley:

my bad mate! :sweat_smile: check this out, this is the script responsible for picking up the shield

1 Like

I see 2 viable options:

  • give this actor a CAC upfront (it can have no class assigned) and only assign a class when a Shield is picked up. Setting class to None would destroy existing shield; setting class to a Shield_Class would destroy the existing and spawn a brand new one:

That’s be the most straightforward and my fav providing I understood what is needed correctly. This way you do not need to instantiate / juggle new child actor components. Probably the best option unless you have 1000 spaceships, making a mobile game and need to worry about memory footprint.

  • do it dynamically like so:

We start with no CAC, when a Shield is picked up, we add a component; we reuse it when a new shield is picked up. The component can be, optionally, destroyed.


There’s more ways but everything else I can think of seems over-engineered.


Essentially, the ship / robot (? :person_shrugging: ?) already has a bunch of CACs, each dedicated to a relevant sybsystem:

image

We do not Add / Remove components at run-time, we replace the class of the relevant CAC instead.

hey thank you so much!,

i feel more lost to be honest. i like the first option but somehow it feels complicated like what dose give this actor a CAC upfront what is upfront mean? and how to connect/add this with the script i did? anyway i try to fiddle with it to see if i get it right.

1 Like

If this is your Metalhead player actor:

You can add components from the Add dropdown.

no this is my metalhead

1 Like

And this character runs around and pick ups various equipment, right? Any reason why it cannot own the CACs?

Perhaps these could be CAC’s:

image

That’d simplify the whole thing dramatically. You wouldn’t need to attach / spawn new components.


Do note that we have no clue how you organised any of this beyond what you tell us. As in, no clue what the spawner are for… It seems quite modular in nature.

If you must dynamically add / remove comps:

The reference is critical here.


I do not understand this bit:

You already have a Child Actor Component. Why are we adding another one?

ok I’m not a programmer nor a coder I’m artist and designer, and i did all of that by watching tut and asking around plus copy & past some cods. do you have discord? i think it would be much easier for me to show you while streaming!

1 Like

i believe because the character can equip the 3 shields together

Screenshot_6

1 Like

I’m not a programmer nor a coder I’m artist and designer

Way too late for that, you’re all of those things now. :innocent:


If you do not want to juggle components spawned dynamically at run-time, perhaps the most straightforward solution would be to give the MetalHead empty slots for the shields:

When they pick it up, they can equip it by changing the class of the CAC. You will need to filter what is what, ofc. But seeing what else you’ve got, that should not be an issue. Inheritance in place already, nice.

i guess so unfortunately… :upside_down_face:

yeah i think i need to do that, but take a look at this maybe it will clarify something:

if you noticed on the outliner when picking up more shields they actually stack inside each other for example if the shield takes damage and get destroyed the other shield will replaced it, i hope this make sense

1 Like

I get it, it’s pretty clear - you keep spawning new components:

That’s why I suggested do it like so:

And if you must destroy it (the OP):

This way there’s only one.

ok so i should do that in the character blueprint? or in spawner one

1 Like

This is the pickup actor:

It spawns the shield for the player, right? Is this how it works?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.