Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I reference an actor from the scene, inside a custom HUD?

So I have an Actor Blueprint that contains most of the logic of my game. Its called MainGame.

I have a button on the hud and I want to call a method from MainGame.

I made a variable in my hud and exposed it & made it editable but I can't set that variable with my MainGame instance.

How can I fix this?

P.S. Somebody suggested I put all that game logic into a custom GameState since its always one instance and its easy to get GameState but I am not sure that's the intended use of GameState.

Product Version: Not Selected
more ▼

asked Jul 06 '14 at 11:26 PM in Blueprint Scripting

avatar image

123 25 33 40

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I would put your MainGame actor reference in your player controller maybe. This way you can have the player controller spawn it if it doesn't exist or do a quick find by class and store a reference to it if it does. This way your HUD just has to get the player controller, cast it to the proper type, then grab a reference from there.

more ▼

answered Jul 07 '14 at 12:09 AM

avatar image

2.6k 98 16 97

avatar image virusescu Jul 07 '14 at 08:06 AM

@RimmyD But isn't the PlayerController's job to manage the camera and nothing else?

avatar image RimmyD Jul 07 '14 at 04:58 PM

The player controller can sort of be used for anything you want. The nice thing about the player controller is that you will always have one so it is a nice place to house references and logic you will need for making your game work.

I house most of my input handling and game mode specific logic/references in the PC when using just blueprints. I treat the player controller as a central game manager for most stuff.

Simple Example: I have a button that wants to know when the mouse is clicked on it. Putting this trace into the button is bad since you could have 50 buttons in the map, so a single click springs 50 traces. I instead have a single trace in the PC which gets what is hit and tells that object it has been clicked on (if it cares, i use Interfaces to determine this). This way i get a single trace each click.

Someone may have another way to handle this and I'd be curious to know it :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question