*wow* what a nightmare. All I want is to move 1 actor to the xyz of another actor. Come on.

Bare-bones basic ; 3 tiles on the ground, and a game piece that needs to move from tile to tile. OnClick event to get the xyz of the tile, write the values and names into variables and print them no problem. Unreal refuses to let those xyz values get to any other blueprint, incl. the game piece. Casting → Fail. Variable Reference to bp → Fail. Scoured a dozen yt videos. Why do I need a computer science degree to make something this simple work, why not just tell us to write in c++… what are blueprints even for?

I read it as you having an issue with obtaining the reference to the actor that needs to move.

  • is there always going to be only 1 piece to move?
  • if not, how do we choose which piece needs to move to the tile?

Thanks for the quick reply!

I’m planning a strategy game with military units on a pretty large grid, so there will be instances of everything. I assume I’ll be using EventOnClick to select pieces too

But I’ve been pulling my hair out for days trying to simply get the values ( which will print-screen just fine exactly the way I want ) over to the piece that needs to move, when I click on a grid square. I write the value to a variable, print that to screen and it’s correct, but accessing it from another blueprint, I get nothing but the initial value which is set at beginplay. It never updates, except in the grid square’s blueprint.

OK found a workaround.

Using the variable is no good, so I moved an interim object directly with the onclick, then I can use its location instead of a variable, to move the game piece. What a biggity-B.

I wouldn’t, this will become awkward and inefficient. Consider the following:

  • the whole script is in the player controller:

That’s pretty much it when it comes to moving pieces, there’s no need for script in the actors at this point.

This can be quite useful as demonstrated above. Admittedly, moving to Interface Communication is recommended.

Good luck!

1 Like

Wow thanks, cool stuff!

I’ll try this asap and let you know - but I’m a little worried that as soon as the click event is over, nothing after it works. It looks like you’re assigning a variable ( at the end of your script ) and that’s where it stops working, the variable is useless in other functions - as if it’s a local variable, when it’s not. Does that not happen to you?

Thanks again

There are no other functions since we don’t know what else is needed at this point. The above was just a 1 min pseudoscript to showcase the basic comms.

If you want to keep the reference to the piece that was moved most recently, don’t clear the variable (the last node). Technically speaking, there’s should be no need to keep the reference as most other functions would have already returned in the Player Controller, or were delegated to the pertinent entities.

It is really up to you to script it the way need. Do what you must!

1 Like

I was planning to have the player highlight the game pieces and the tiles first, and then commit the move afterwards - so I will need the variables to work in different functions! Do you think there could be something wrong with my project, or a bug running UE on a mac, that might mess up my variables in-between functions?

Thanks so much for your help!

It’s an issue with the script. You do not need to keep references for what you’re describing. And if you need to keep them valid for some other reason, do so. There’s as many ways to handle it all as there are people:


Addressed in another thread:

1 Like

yes that’s my other post, I didn’t know if there was something else I had to do to make it work. I’ll try it again in a fresh project, Thanks