x

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"

Access to game state without cast every time?

I understand concept of GameState, but I feel bit annoyed that I would need to cast it to my class every time I need to read or write variable from it. I have created a macro library blueprint essentially just to wrap around logic for variables stored in the game state. But I am wondering if I can actually store MyGameState instance into some global-ish variable and have access to it from that macro library.

Main thing that is bothering me about this is the need for execution pins whenever I need to cast. Especially for just getting values out of the game state it is rather annoying and not always feasible.

Product Version: UE 4.14
Tags:
more ▼

asked Dec 12 '16 at 12:37 PM in Blueprint Scripting

avatar image

Daniel K.
165 9 21 23

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

1 answer: sort voted first

Hey,

You can convert a cast function pure cast from impure cast. This allows you to leave an execution pin, but also might not be completely safe since you're skipping the error check an impurecast provides.

See below the image:

alt text Hope this help :)

more ▼

answered Dec 12 '16 at 01:27 PM

avatar image

Azarus
1.9k 61 52 191

avatar image Daniel K. Dec 12 '16 at 02:37 PM

Ok thanks, that's surely one way, but still feels kinda odd. Would be much easier in my opinion to have some place where I can store casted game state object into variable upon start (since this isn't going to change in runtime) and then access it directly from other blueprints.

avatar image Azarus Dec 12 '16 at 05:30 PM

You can maybe create a singleton object? Or store these variables in the game instance or game mode?

avatar image Daniel K. Dec 12 '16 at 05:38 PM

Yeah I am kinda expecting it's heading to C++ land for this. Not sure how game instance or game mode would be useful as I would need to cast those too only to get casted game state :) That seems already easier to cast game state right away :)

(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