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"

Custom GameMode and GameState not working?

Ok, Im new to UE4 so lets put that out there ;o) I have been through all the code tutorials tho, and have been a programmer for many years.

Im using Visual Studio 2013 Express with UE4 4.2.1 on Windows 7 Professional.

I have created a ThirdPersonCode sample project. I have created a UObject based controller class that I want to abstract some calculations that i dont want to do in a Blueprint. The idea is this contoller will be used inside the GameMode::Tick method to update a USTRUCT in my GameState class for use within Blueprints.


 class ASandboxGameMode : public AGameMode

     virtual void Tick(float deltaSeconds) OVERRIDE;
     /** */
     UMyController* m_myController;

I define my GameStateClass and create one of these Controller objects in my GameMode constructor

 GameStateClass = ASandboxGameState::StaticClass();
 // Construct MyController for game
 m_myController = NewObject<UMyController>();

Then I have my Tick method

 void ASandboxGameMode::Tick(float deltaSeconds)
     // Update Game State
     ASandboxGameState* gameState = Cast<ASandboxGameState>(GameState);
     if (NULL != gameState)
         gameState->Data = m_myController->Data;

So far so good you might say ... or not shrugs

Here are my issues that if you can help I would be very grateful

  1. When I debug in the constructor I see this(..."SandboxGameMode"_0) but in Tick I see this(..."BP_SkySphere_C") as if there are two different instance of game mode calling different parts of the game mode methods? wierd ... I never seem to see "SandboxGameMode"_0 in the Tick method or "BP_SkySphere_C" in the constructor.

  2. In the GameMode constructor my m_myController is constructed fine, in the Tick method it is undefined as in (Name=???, Number=???)? How can that be?

  3. GameState is always NULL in the Tick method even tho my GameState constructor is called

  4. In my GameState class the constuctor is called and properly executes, however even tho the GameState is always NULL in the Tick method, it steps into a GameState that is undefined (Name=??? ....)

  5. When I am debugging the if (NULL != gameState) line does not execute ... the debugger just skips it

None of this makes any sense to me as far as standard C++ programming goes, but there may be some UE4 specifics that I am missing.

This also seems like simple basic stuff that should not have been a stumbling block for me for so long.

Hoping someone out there can point me in the right direction.


Product Version: Not Selected
more ▼

asked Jul 16 '14 at 07:07 PM in C++ Programming

avatar image

596 31 77 51

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

1 answer: sort voted first

Somehow my Unreal Engine installation must have been corrupted as every new project exhibited the same behaviour.

I installed 4.3 and created everything again from scratch :o( and the problem has not reappeared.

more ▼

answered Jul 20 '14 at 12:31 AM

avatar image

596 31 77 51

(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