I have a simple system where the player can pick up firearms that are on the floor; if the player enters a sphere collision that surrounds the weapon actor they are able to pick up the weapon by looking at it and pressing F. When the player enters that collision sphere it sets a player variable to be the player actor and then it can use that variable to get the referenced player actor whenever it needs it.
When the weapon actor is picked up: The weapon that was on the flor is destroyed and it spawns 2 new child BPs of the weapon that was picked up on the player, one is visible to the player but hidden for all other actors, and the other is hidden for the player but visible for all other actors. It is set up this way because there are 2 rigs on the player, one being first person arms, and the other being a 3rd person full body model.
The problem I’m having is that the player variable inside the weapon BP gets set to null when the weapon is picked up, and I’m really not sure why. my best guess is that it gets set to null because the player variable is only set when the player enters the sphere collision, and since the sphere’s collision is set to false so that other players cant loot it, it sets the player variable to null.
I’ve tried testing if the guns BP works after it is destroyed via blueprint interfaces and it seems to work, but its just that player variable that doesn’t work.
I’m currently stuck but if anyone has any ideas I’d love to hear them! I’ve attached some images of code below just in case it’s something hidden in plain sight…
[Overlap code, Player ref is a BPI that gets a reference of the player from the target player. This is inside the Weapon BP]
[Interaction code, called from the player’s BP after pressing the interaction key. This is inside the Weapon BP]
[Loot Weapon event that was shown in the previous screenshot. This is inside the Player BP]
[Set w/Notify Looted Weapon, Ive cut out most of this notify because most of it its just spawning the guns based on different conditions. Main thing relating to the problem is this part shown. This is inside the Player BP]
[Set Weapon Player Ref Event, This is inside the Weapon BP]
It always initially returns the player upon pickup. As shown below (Green and dark green messages)
but when i call it to print the name via a debug key, it returns null…
If anyone could help me in understanding this it would be great. Thanks.