Implementing interfaces

I want to create a script where when my character is near a building a ui pops up and allows the player to press multiple buttons that create a worker or unit type.(i was able to do this) I implemented an interface that i called INI_building and within that, i created a function called createworker. In my UI_towncenter i create a button and put a message node for my create worker function when the button is pressed it should trigger the event in bp_towncenter. In my BP_towncenter i implemented said function and hooked it up to a print string & when i click on the button the function never delivers the message (i guess thats the way to say it cause the string never gets printed) I guess my target should be something else or if it should be done within another blueprint like the bP_character. Which is my main character blueprint for camera movement.
help.mkv (17.1 MB)

How do you set up the TownCenterRef? What is it referencing?


this node is just a class reference not instance reference。
like ‘Singer’ not ‘Michael Jackson’。
you should use ‘get actor from class’ node,or select actor in world then right click in level blueprint ‘create a reference to (your blueprint)’ to get instance reference。

1 Like

It is referencing Bp town center i g


Okay so in doing that. what will it accomplish? If i create it in the level blueprint how do i use that where I am using the towncenterref in the ui_towncenter?

A reference is just like a pointer, it has to point to something.

Like zhuangbiiii says, you’ll need to create an instance of it and then point your reference to it.

1 Like

Oh, wait I got it to work. So by creating the reference in the level blueprint u can then use those references in another blueprint without casting to the blueprint or anything?

there is easy way to send a instance reference。

1 Like

yes you get it!

Thanks for the help all of you guys! Now I gotta figure out how to spawn the worker when I click the button not sure how to get the world transform of the arrow to use the spawn actor from class to plug it into the transform.

1 Like