Pass variables back and forth between 2 classes?

I have a variable that will act as the anchor for my player’s hand to snap to. The location it needs to snap to is a Box Collision Object within a weapon’s blueprint. The place that the Box Collision’s location is supposed to be used is within my Player01 blueprint file.

So how do I get the Box Collision Object from my weapon blueprint to be used as a snap point in my Player01 blueprint? I sort of need it to work like this:


and store the value of Snap into a value within the Player01 blueprint. when the weapon is picked up, it will request the held weapon’s Box Collision Object. Somewhere in the weapon’s blueprint, it will return the Box Collision Object sort of like this:

I just coded this real quick to sort of give a visual of what I am aiming for. From what I understand, Blueprint Interfaces are only one way/ What I need is basically a 2-way blueprint interface. How would I go about doing this? I also do NOT want to cast because this system has to be dynamic due to there being more than 1 weapon in the game.

1 Like

Hey, just to clarify. Your main goal is a weapon pickup?
Like this?

2 Likes

Essentially yeah. The end goal of this nightmare is to have the XY coordinates of the box collision in the main player blueprint. the box is an object in the weapon’s blueprint and acts as a snapping point for the player hand
Edit: I should also mention that the game is a 2D sidescroller that uses sprites

1 Like

Just to throw in another idea: your weapon does have a “origin point” by default. You can set it so it ligns up with the handle of the weapon. There is a node called Attach to Actor Node. This will automatically track the object (which can be chosen dynamically) to its specific point on the Player (this specific place is most often a Socket. There are Sprite Sockets that are made for that purpose.

2 Likes

I actually really like that answer. I was sort of going about it backwards but totally forgot that I could easily just assign sockets to the sprite image itself and index the grip points that way. The things you forget when you’re tired, lol. Thanks! :slight_smile:

2 Likes