instances are a huge hurdle in blueprints

Pretty much every time I learn from a tutorial or from advice here, it all works great - until it needs to work on an instance of an actor, then all bets are off, nothing I just learned works, pins are different, functions don’t exist etc., and I’ve found no way to isolate one instance from the others, consistently. Hit Actor seems to work but I can’t find any way to put that in a variable, so it’s of very limited use. Are there any guides on how to work with instances in blueprints? Like pawn pieces on a chessboard.

Thanks for any leads folks!

basically, pretty much almost everything you do in BP is playing with object reference (the blue variable). an object reference is an instance, refering to an actor instance in your scene or somewhere else. class reference (the purple variable), you can see these purple when you want to create an instance from a class(those BP in your content browser).

If you want to save reference as variable, you just drag out the blue line and hit promote to variable, then you can access the reference from somewhere else. For a chessgame, each pawn is an instance, you need to decide which one you are moving with your controller, maybe a trace from your mouse cursor, get the hit actor and modify it.

Thanks for the quick reply - I have put the instance into an Actor variable, which gets set when I click on my game piece and there’s no problem with that, but as soon as I involve any other blueprint, like for the board square I want it to move to, the variable refuses to update, and only works for one particular instance, never any others. Am I doing something wrong - does that sound like a familiar issue? Whether casting or using BPI it gets stuck on one instance.

So this is what I got - print the variable at onClick, and it changes when clicking on different instances.

But print that same variable after connecting the BPI, and it never changes.

What’s your movement setup? Is it Click on Game Piece, then Select the Move to Board position?

If So, Event Actor OnClicked should be in the controller. You’ll Need another OnClicked to get the position. This will give you two variables… Hit Actor (game piece reference) and the Board location (Vector, or reference to the board tile).

From there you’d call an Interface event on the Hit Actor and pass the Board Location as an input.
Inside the Game piece class you’ll implement the event. Take the Board location and have the game piece move itself to that location. Set actor location (lerp) or teleport.

You should have an interface event in the Controller that the Hit Actor calls when it has finished moving. This event should clear the Hit Actor and Board Location variables (set null) and handle in other executions.

1 Like

Awesome, this is one of the things I’ve been trying to find out! The ‘what-goes-where’ kind of guide, b/c it’s not always obvious - thanks heaps!

If the OnClick event is in the controller, how do I determine if a game piece or a board square, was clicked on / which variable to assign? I tried Get Class and Get Object Class in order to see if it == a game piece or a board square bp, but those require “In Asset Data” and are a dead-end to me. How can I have 2 OnClicks in the same event graph without things getting mixed up? Break Hit Result doesn’t give me anything I can use for this.

Man this is crazy hard. Really really trying to avoid having to be spoon-fed but UE gives me no choice! I studied a chess tutorial and others for months before trying to make just a couple game pieces move on a board. I can do it in the most rudimentary fashion but trying to add a selection step or anything else has been impossible -

Not sure if this completely applies, but everything that is instanced can usually be promoted back to whatever it was before it was an instance. I have this issue all the time, where i need to edit one particular instance some something. i just click the instance in the editor window, then hit this promote button:

This game will be spawning game pieces so I don’t think that applies…? But that’s great to know, I’ll try to remember it - thank you!

But that begs the question ; can you manipulate the details / attributes from inside blueprints? Seems like there might be a node for that eh?

1 Like

There’s a million different ways to handle that though…

It depends very strongly on what it actually is you want to do, instances are a huge hurdle in blueprints - #4 by tobygaines ← that is one way to do it ofr instance.

There are 4 main ways to do it.

1: You do as you did in that post, you perform an action or use an overlap/hit event to get the actor instance, then you use that instance reference to do whatever it is you want, if you need to access actor specific functions or variables or events, you can use all that by using ‘cast to blueprint’ nodes. For example like this:


2: You implement functionality inside the actor you want to affect and trigger them conditionally, here are some events you could potentially use for that.

3: Use the physics.
Move with Physics:

Grab and hold with physics:

Move held object with cursor (needs to be on-tick or similar):

4: Use pawn/character movement component. You can find examples of their use in the reference character blueprints. And you can call upon it from another blueprint with a cast (this works for both characters and other pawns):

Sorry for late reply, I went out of town on Friday.

Anyway, You would need to setup a trigger to toggle logic flow for the Onclick event.


Note that After the move is completed I reset/clear the set variables.

2 Likes

This is awesome - I’ll try it out, and study it too - Thanks!