No announcement yet.

Very Basic UFUNCTION Issue

  • Filter
  • Time
  • Show
Clear All
new posts

    Very Basic UFUNCTION Issue

    Greetings! Super-simple issue but ... I am trying to call a function from a custom game mode in Blueprints.

    In my game mode .h:
    	UFUNCTION(BlueprintCallable, Category="Test")
    	void AddNewGame();
    In my game mode .c:
    void AMainGameMode::AddNewGame(){
    	UE_LOG(LogTemp, Error, TEXT("OKAY WORKING"));
    I then edited the level blueprint to create a basic test UI. I added a button that, when pressed, is supposed to trigger the function, but doesn't. The blueprints look like:

    Click image for larger version

Name:	img1.PNG
Views:	1
Size:	58.0 KB
ID:	1156228

    Here is the reference to the game mode object in blueprints:

    Click image for larger version

Name:	img2.PNG
Views:	1
Size:	25.4 KB
ID:	1156229

    The button works fine and the game mode is being loaded just fine; I can put the function in the constructor and it outputs correctly.

    Does anyone know what is going on here? Thanks!
    Last edited by irdc; 07-24-2015, 03:25 PM.

    Are you filling the MainGameMode variable with the current game mode?

    Use the Get GameMode node and cast to your custom mode.
    Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!