SpawnActor/Destroy Glitch

Hello, I’m fairly new to Unreal Engine and looking for advice.

I’ve been following a free programming tutorial from 2023 and have hit hiccups once in a while. Currently I’ve got a 3rd person character which can “interact” using Action Mapping, the interaction in question is Destroying an actor that I made from the guide called BP_Pickup. It uses event overlap plus the interact key “F” in this case to Destroy said actor. The actor BP_Pickup is a custom golden cube made within the engine.

However there are a few strange issues. Firstly I have three BP_Pickup’s in editor mode “BP_Pickup, BP_Pickup2, and BP_Pickup3” when I press the green play button one more is supposed to spawn from a TargetPoint Instance. Running the session spawns a second BP_Pickup 2 with gold text to spawn, and another 4th cube labeled “BP_Pickup4”. And when going to destroy the actors’ it sometimes doesn’t work, or destroying one cube destroys two in separate locations at once.

To summarize the issues I’m having are duplication of a previous actor on spawn, and a destroy actor working intermittently.

Thanks for any response.

1 Like

Best to show the code?

I’m wondering about input consumption, for the F key, for example

If its on, all BPs will respond, otherwise only the the first one placed in the level.

1 Like

I’m not familiar with input consumption, however I will look into it later today.

Here are the screenshots of my Blueprint “Code” and of the issues in action.

Spawning Existing Actor “BP_Pickup” at TargetPoint (Code in BP_Character not BP_Pickup).

Will try more screenshots today, the forum is only letting me post one screenshot at a time due to being a new user.

Just checked consume input is checked, though this is only visible when I create the same F blueprint that you have. Normally I don’t have that blueprint in my code. So I have no idea whether this is checked without said blueprint. I’ve been relying on InputAction created via the project settings. Thus I had made an InputAction Interact bound to F.

The project settings do indicate that the action and axis mappings are depreciated, which I haven’t figured out yet. As this isn’t mentioned mentioned anywhere in the 11 hour tutorial that I’m following, making it possibly outdated.

This is another section of my code relating to the interact and overlap functions for “picking up”/destroying the actor.

1 Like

I think you have the same options on the interact key

1 Like

The Consume Input is available and already checked on the Interact Key. So if it isn’t the consume input could it be the “hitbox” for when the character is considered overlapping my object in question?

This is the last screenshot I have of actual blueprint code that is related to this issue, otherwise it’ll be character movement blueprints and Input from the project settings.

Maybe I could also switch the location of overlap blueprints from BP_Character to that of BP_Pickup, albeit not ideal in an actual project with this feature repeated hundreds of times on different objects but it might change the consistency. This sort of reminds me of an issue I had when learning Scratch for a CS50 class, where a sprite/actor was moved before relevant counting code was able to run.

1 Like

That’s the problem. One of the blueprints is taking the input from all the others.

You need consume turned off, then the will all respond, and you can use a method like overlap to know which one should respond.

1 Like

Should I turn consume input off of everything? Including Axis Mappings for movement, not just the F and Interact action that I made?

I turned off consume input for both Interact and the basic F blueprints and issues still persist after compiling. Also the original BP_Pickup Actor never seems to respond to the F key, while the others are just intermittently.

Here’s a picture of the actor duplication of BP_Pickup2, it’s kind of hard to see but in the item label under the Outliner you can see a yellow BP_Pickup2, and a gray BP_Pickup2. Not sure if this is linked to my current interact issue, or if its separate.

1 Like

I just wrote something like you have.

The pickup looks like this

Notice you need the collision volume around the cube, otherwise the player has nothing to overlap with.

Then, in the player

So, apologies, you don’t in fact need to worry about the ‘consume input’ thing. That would only be if the input event was in the pickup BP.

This code works.

pickup

1 Like

Thanks this made the interactions more consistent, still not perfect probably because of the weird duplication issue that’s occurring, but this definitely helps.

Would there be a reason though that an actor wouldn’t be able to be “destroyed” with this code? As the original BP_Pickup refuses to respond to the interaction.

Thanks again.

1 Like

I’m assuming you have other code as well as what you’re showing?

What I have posted here, is enough for it to work, as you can see :slight_smile:

The only other code is sensitivity code for camera controls, and a Float Get X for return node for as an introduction to vectors.
What seems to be the unsolved issue is the spawning of an extra BP_Pickup2, and the original BP_Pickup not being able to be interacted with after it falls to the ground via simulate physics.

Anyways though you’ve helped me out quite a bit, I’ll keep on working to figure out the rest of this problem.

Thanks again.

Ah. That will be because the collision volume is not present, or still somewhere else on the map. Try making it visible in game.

1 Like

Ok I made the collision volume, or “yellow/red hitbox” visible in game. This shows that collision volume isn’t following any of the BP_Pickup’s affected by movement. Which includes the original falling from the sky, and the additional duplicates spawned at the TargetPoint Instance hit each other and thus move away from “their” collision volumes.

So is there a simple box that I need to check to get the collision to follow its particular BP_Pickup, or do I need to make follow code via blueprints?

Update: I fixed the collision box not following the golden cube BP_Pickup, the issue was derived from the shape/material being assigned to a subcategory of BP_Pickup under “Static Mesh” rather than being assigned to Static Mesh.

Once the golden cube was assigned to static mesh, and the simulate physics box was ticked then the “hitbox/collision box” would follow. Essentially it was a placement or folder problem.

However now the only issue that remains is the TargetPoint, for spawning a golden cube, creating duplicate cubes upon play.

1 Like

Another update, today I was messing around and deleted the extra character that was placed on my map. After this when pressing play the duplicate cube spawned at the TargetPoint no longer spawned. Conversely adding another BP_Character to the map spawns another duplicate cube on play.

Essentially the number of BP_Characters in the game dictate how many cubes are spawned at the TargetPoint. Which is fine for something designed to be singleplayer. But say I wanted to make a multiplayer game, with only what I currently have, how do I disconnect this spawning from the player/s and keep the pickup/destroy actor interactions.

1 Like

There’s an option on the spawn, you get to choose what it will do if something’s in the way. Just choose ‘always spawn’.

I tried to change it away from always spawn since that is what I had enabled, and nothing changed. Am I misunderstanding.

Also to reiterate the final problem that I’ve gotten myself into…

BP_Character exist on map, upon play new BP_Character is placed (and controlled by player). So now there are two BP_Characters. Elsewhere at a TargetSpawn BP_Pickup spawns on play. However, the number of BP_Pickups spawned at the location will match the number of BP_Characters that exist on the map.

How do I prevent number of BP_Pickup (Cubes spawned) from = number of BP_Characters (Player Enities)?

Thanks again for putting up with me for as long as this thread has gone on for.

1 Like

Ok, it sounds like you’re spawning from the character BP? That’s why :slight_smile:

Thanks.

The tutorial I’m following did that for some reason. Overall though thank you for all your help. I’m probably going to create an “entity” that spawns world objects when the player is within certain distance of said entity.

Anyways thanks again, the questions I’ve had with this topic are pretty much resolved now. So hopefully future development I do will go smoothly, and who know maybe this thread will help someone else out as well.

1 Like