Download

Send actor reference to character to modify value

Hi there.

I’m running into a small problem. I have a blueprint called Chest which includes only a skeletal mesh of a chest in which I do a Sphere Overlap Actors to check if the player is within its range, but then I want to change that specific chest’s “isOpened” boolean variable so I can open it with a button press, but I can’t seem to get it working.
I thought on just getting the “Out Actors” from the sphere overlap and set it in another “Actor” variable in my character blueprint and from there I could just set it to true. However, all that doesn’t seem to work properly. What should I do?

Hello,
If there is no particular reason to use a skeletal mesh, you can use this set up from tim hobson to open / close chest. Use overlap to set your bool and replace overlap by your activating key to open close with a condition check : https://forums.unrealengine.com/showthread.php?30924-What-is-the-best-way-to-create-openable-crates-chest-shells-etc&p=122815&viewfull=1#post122815

I do need it to be a skeletal mesh because I have an open and close animation for it, but that’s not the problem. The chest works properly if I do just a proximity check with the overlap functions, but if I place a lot of chests in a map, the “Press button E” function needs to know what “bIsOpened” to check. That’s the main problem. I don’t know how to make MyCharacter blueprint to get a reference to the actor I’m in proximity with. Thus, I want so when I’m in proximity, the chest blueprint send a reference to itself to mycharacter.

To put it clear, my idea is:

When chest is in range but isn’t opened, it should show a prompt saying “Press E to open”. Then if you press E, the chest opens and stays open.
All of this works no problem with a proximity check because mycharacter doesn’t need to know which chest needs to be opened.

Ok then you may better need to set your overlap in your character or use get overlapping actors and from the loop check if a chest is overlapping and if yes then you’ll have your reference. If not the way seems to be a get all actors and use a value to know which one is overlapping.

Edit : I would set the overlap in chest bp to show the message and the get overlapping actors on e event in character to open chest.

I can get all the chests in the map with Begin Play->Get all actors(Chest)->Chest Array from my MyCharacter BP, but then how do I know which chest is the one I’m overlapping?

For me, the fastest way would be that : Upon your character blueprint, under your chest (here bp_door) character : when you hit e you check that you overlap a chest, if yes then you open it. chest : when chest is overlapped text appears.
overlap.jpg

Thanks, that seems to work!