Sphere Trace Issues

Hello everyone,

I am fairly new to ue4 and have been trying to make this inventory system for over two weeks now and want to give up but im dying to get past this stage so I can move on to better aspects of my game. What I am trying to make is an inventory where I: - Walk over to an Item and open the inventory, a multi trace shows all nearby items on the ground, or you can press a button to pick it up off the ground by a sphere trace - The item gets destroyed and adds to my inventory. Simple Right?

My problem is that when i walk over to pick up any weapon it just simply doesnt cooperate with my sphere trace and the cast fails, but consumable work perfectly fine and go into my inventory.

Any ideas on why my weapons dont get destroyed and go into my inventory from the sphere trace?

the only thing i would venture to guess based on the information given is that your weapons dont inherit from the “parent” class.

if thats not the case i think ill need more info. also i wouldnt name your actor parent if thats what you did. parent is one of those reserved words that arent used for names since its something thats also used in scripting.

It does not appear that your Sphere Trace fails, but that you are attempting to cast the object to an incompatible class. Perhaps reflect on why that may be.

To be honest i dont know what info i need to give because the weapons dont make it past the casting part. i could show you the code when the items go into the inventory but thats pretty pointless as it never makes it there and its not an inherit problem because every item in the game comes from the “parent” with item info inside the class that i change on the child class. All consumables use the same item info as the weapons which is what doesnt make sense on why it doesnt work.

How can the weapons be a incompatible class if it comes from the same “parent” class as the consumables?

whatever your trace is hitting doesnt inherit from the “parent” class thats why your cast is failing. my first step would be to print the hit result name and ensure that the trace is actually hitting your weapon. if the trace is hitting your weapon and the weapon inherits from class “parent” then it shouldnt have an issue and fail.

beyond that seeing how your trace is setup and how the “parent” class and the weapon blueprints are setup could possibly be helpful. you never know when something could have been accidentally set to a wrong setting like say a pickup not blocking the visible channel or something crazy like that.