error collecting enemy drops with final project for college due 3 days from now.

I made three item drops for each of my three enemies in the game. they have a collision box with overlapping events enabled. I made it so that when I overlap with an item and press X on the keyboard, the item is destroyed and an integer is raised by 1. The problem is that sometimes when I pick an item up, it doesn’t count and then I get a bunch of errors that say “Blueprint Runtime Error: “Attempted to assign to None”. Node: Set Integer (by ref) Graph: ManipulateIntInternal Function: Execute Ubergraph Tomato Drop 1 Blueprint: tomato_drop1” for example, and also “Blueprint Runtime Error: “Accessed None trying to read property K2Node_DynamicCast_AsBP_Hero”. Node: Set Integer (by ref) Graph: ManipulateIntInternal Function: Execute Ubergraph Coocoo Drop Blueprint: coocoo_drop”. my enemies are vegetables by the way. Its essential that collecting these enemy drops works, since they are required to finish the game. Also I seem to have a problem with collecting order, as I can only collect the enemy drops in the order that I defeated them, which is also problematic.

From the errors, I assume you’re trying to set a variable in the player. It seems you’re either using a pure cast and not checking if it succeeded, or casting where failed also uses the casted variable. Either way, the result is that you don’t have a valid reference to your player as a hero- make sure that the value you’re passing in is actually valid as well.

You’ll need to show us your blueprints for us to get an idea as to why it’s happening beyond this.

1 Like


this is how I collect an item. after some testing, the problem seems to accure when I defeat an enemy that is so close to me that the item that drops afterward appears too close and so it starts its life when im already inside its collision box. when i walk out of and into the collision box, things work fine. i dont know how to prevent that problem though since it should work in either of these situations. It is essential that the player can collect an item that spawns close to them without them having to walk out and in to it.

You don’t need to have a gate and input modification. You can get rid of the gate or Disable/Enable inputs- you only need one.

Ah- a classic. Unreal won’t call a begin overlap event for anything that is already overlapping when spawned. You’ll have to check at begin play. Unfortunately that isn’t compatible with how you currently have it without copy pasting, so I’ve taken the liberty of modifying it.


I made two changes- your input key is now isolated, and we account for the issue I mentioned. I had to isolate the input key otherwise we’d be drawing from a non-existent variable.

thanks, I actually think I’ve managed to solve it by adding a “cast to BP_hero” with “Get Player Character” after the gate, connected to the amount of items collected. for now it seems to work okay, but incase the error re-appears like errors love to do, ill use your advice!

Ah- that would work for the errors. The solution I sent aimed to also solve your problem with the below problem.

It’s essentially the same thing, but yours probably solves a problem that would accure if the game would start with the player inside the collision box of the item, but since you must defeat an enemy in order to get the item, theres nothing that revolves around the beginning of the game. I think. from how I see it, the drop blueprint knew I was inside of its collision box upon spawning, but after the gate opens it didn’t know where to get “collected tomatos” from since the cast was before the gate and thats somehow a problem. so casting again after the gate made sure the cast was successful because it knew where to get “collected tomatos” from now that its after the gate. im not a programmer, im a designer so idk if anything i say is actually true, but thats how it made sense to me. again thanks for the help!

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