Puzzle Blueprint Communication --HELP

Hi all! Need some Blueprint help. I’m setting up a puzzle game and the interaction should be fairly simple, but I’m new to this so I’m all over the place!

Here’s the basic setup:

I’ve made a Class Blueprint “puzzle base” with a collection of 11 actors (want to look into making these child blueprints but I think that’ll have to wait).

Then there’s a few different, separate Class Blueprints for the 11 puzzle pieces.
I have made the puzzle pieces interactable (they can be picked up) in two ways:
1) By replacing the standard BP_PickupCube’s static mesh from the VR template. This means I can pick it up with Vive controllers.
2) By setting up a LineTraceByChannel function driven by a custom pickup event in the FirstPersonCharacter blueprint.

I need to make these 4 elements talk to eachother, probably by querying the status of the puzzle piece to see if it a) is overlapping the right component and b) has been dropped.

Once I know that I need to:
1) Tell the “puzzle base” that the “puzzle piece” is overlapping it and change a parameter of the material. Currently doing this with an overlap event connected to a cast node in the puzzle base blueprint.
2) Tell the “puzzle base” that the “puzzle piece” is overlapping it and has been dropped, changing the material entirely. Haven’t made this work yet.
3) Tell the “puzzle piece” that it’s overlapping the correct component of the “puzzle base” and that it has been dropped, toggling visibility. (Maybe Destroy Actor would work better here?)
4) At the end, tell the “puzzle base” that all of it’s components have been switched to the final material (basically the puzzle is complete) and then have it play an animation involving all pieces of the blueprint, maybe triggering other actors too.

I want to use the existing Blueprint Interface (PickupActorInterface) for the BP_PickupCube, but I have to test on my workstation, so I set up a linetrace pick up event using the standard FirstPersonCharacter Blueprint.

What’s best here? Blueprint Interfaces? Casting? Event Dispatchers?

Thanks very much for any help!


On these forums I often see wording regarding Blueprints talking to each other or communicating. I don’t see object interactions talked about like that on other programming sites like StackOverflow and never heard it like that in school. It is a very bad analogy and will make your life more complicated than it is. Where the problem I think is, is that there is not a basic understanding of the difference between a class and an instance of a class.

At any point in code with a reference to an instance of a class you have access to all it’s functions and data. Unreal has built in ways to get the reference, Such as get player controller, or get all actors. Those give you the base type, so you attempt a cast to the type that you want, if it succeeds then you do what you want, if it fails you try another one or just know it’s not what you are looking for.

You call a function or set a variable, or call an event, you don’t tell. It may help get rid of some confusion to think in those terms.

Easiest way is to just get it working is make some functions on the puzzle base

The simplest way for you to do all this is to put a collision component on your puzzle piece actor like you did. You pull off the pin from it and try to cast it to your type. That is your first step and you said it is working.

So, on your puzzle base class you have variables to denote whether your piece has been dropped?

Only destroy the actor if your not going to need it again, just setting visibility is better if you want to toggle it back on.

For number 4, just add a variable that states that they are all on.

There’s more than one way to do this. Instead of variables in the base, you could have them be in the pieces, and a function in the base that loops through all the pieces and tests if their variable is true.

There is no “best”. You always will have to cast to tell one piece apart form another. Interface’s are for when you are calling a function common to all of them. I don’t think you need to make your own event dispatcher because it’s based on overlaps so collision components can handle that for you, just respond to the Overlap events…

Thanks ! I read you post a few times over the weekend and had a bit more success on Monday, although I had to use Event Dispatchers because I couldn’t make it work by setting a boolean variable on the blueprint for the puzzle base. I’m sure that there is a much better way to do this than I am currently, but Event Dispatching it was the only one that allowed me to call a function on the piece and the base while the object was overlapping.

I’ve taken a few screenshots to describe my setup:

This is a test setup, currently works by allowing a FirstPersonCharacter to pick up pieces with the F key. The red collision box around the puzzle base binds the event dispatch and the player calls the event by dropping the item. Since I need to test with the FirstPersonCharacter, this is called from that blueprint, and is called from the puzzle piece blueprint when using the Vive headset and motion controllers.

Here is the Puzzle Base Blueprint:

A Puzzle Piece Blueprint:

And the FirstPersonCharacter Blueprint I am using for testing:

As you can see with only three pieces it already looks more complicated than it should be - plus I get the feeling that I’m using really shaky referencing with the Get Actor Tag.

Is it possible for me to set up a single blueprint for a puzzle piece and then make the other pieces child blueprints, and then identify which actor is touching which component by another means? How If anybody has any advice or suggestions they are most welcome.