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"

How to call GameMode function from another Blueprint

Hello,

I'm trying to call a function "Hide World" that lives on my game mode blueprint from my main player character. This function handles hiding objects in the world. I call the function from the character via a button press. It's all pretty simple. However, the function on the game mode isn't being hit (no breakpoint is hit), but the call on the character blueprint does hit the "Hide World" function and moves along to the next execution pin, without actually hitting the breakpoint inside "Hide World".

I have created a variable for the game mode, of which I only have the one default one that came with the sample SideScrollerCharacter Unreal project. I created a new variable in the character blueprint and gave it a variable type of Side Scroller Game Mode from it's dropdown and flagged it as editable via the tips on some of the other similar links.

As you can see, it already knows the specific target, and even yelled at me when I tried to cast it. Do I need a target instance instead and perhaps this is just hitting some default blueprint and that's why it's not working? On my game mode function breakpoint I have no filters on the breakpoint, so it should trigger on any blueprint call.

Any tips are greatly appreciated. Thanks!

alt text

alt text

Product Version: UE 4.10
Tags:
more ▼

asked Feb 28 '16 at 09:49 PM in Blueprint Scripting

avatar image

Elbryan Wyndon
33 4 6 11

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

3 answers: sort voted first

You can use the "Get Game Mode" node to get the current instance of the game mode. That should fix the problem for you.

more ▼

answered Mar 01 '16 at 12:41 AM

avatar image

Sentura
420 32 9 27

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

did you initialize the variable? so for example, in your character's blueprint, on begin play, did you call 'get game mode' and cast the returned value to 'yourCustomGameMode' and then set the variable 'GameMode' (by the way, this naming might confuse you down the line. you may want to rename it to something more specific) to your objected returned from the cast?

more ▼

answered Feb 29 '16 at 06:16 PM

avatar image

paradoc
1.2k 49 31 87

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

Excellent advice from you both! This not being an actual programming language makes me forget obvious things like initializing my variables. :P

more ▼

answered Mar 06 '16 at 12:26 AM

avatar image

Elbryan Wyndon
33 4 6 11

avatar image Sentura Mar 06 '16 at 10:59 AM

Glad I could help. Could you please mark the question as solved by the answer of choice? Thanks. =)

avatar image Elbryan Wyndon Mar 06 '16 at 06:43 PM

I tried and couldn't find out what button it was. Thanks for following up, got it this time. :)

(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