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"

Changing GameMode when loading new sublevel

Hello,

I am having issues having my game load a different gamemode when loading a new sublevel. I looked at as much documentations and tutorials as I could however I haven't been able to find an answer.

I have created a new gamemode the following way

 UCLASS()
 class TESTGAME_API ABkInvadersGameMode : public AGameMode
 {
     GENERATED_BODY()
 
         virtual void Tick(float DeltaSeconds) override;
 public:
 
     ABkInvadersGameMode(const class FObjectInitializer& PCIP);
     
     UPROPERTY(EditDefaultsOnly, BluePrintReadWrite, Category = "Game Rules")
     int32 numEnemies;
 };

All the cpp does is the following

 ABkInvadersGameMode::ABkInvadersGameMode(const class FObjectInitializer& PCIP)
     :Super(PCIP)
 {
     // default numEnemies
     numEnemies = 1;
 }
 
 void ABkInvadersGameMode::Tick(float DeltaSeconds)
 {
     int i = 0;
     i++;
 
 }

After doing this I opened one of my sublevels that I load via a blueprint using load stream levelalt text

and set my gamemode level override to my newly created gamemode

alt text

However when i set a breakpoint in my gamemode, the constructor gets called as soon as the game starts, not when the gamemode is loaded and the Tick function never gets called.

I've tried looking as hard as I could and i am wondering: Did I setup something wrong? (probably) does GameMode override not work with sublevels and or streaming? Should I be doing this differently?

Thanks for the help! :)

Product Version: UE 4.7
Tags:
load.png (80.7 kB)
more ▼

asked Jun 18 '15 at 04:10 AM in C++ Programming

avatar image

Kondoriano
6 1 2 4

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

1 answer: sort voted first

You have to use OpenLevel. Otherwise you are loading the level and merging with the existing level (you can't have 2 gamemodes).

More info about level streaming here https://wiki.unrealengine.com/Blueprint_Manual_Level_Streaming

If you would like to change game mode with LoadStreamLevel you have to do it manually.

P.S. You forgot Super::Tick(DeltaSeconds);

more ▼

answered Jun 25 '15 at 03:50 AM

avatar image

MiniTurtle
259 17 10 18

avatar image Kondoriano Jul 01 '15 at 03:55 AM

Thanks!! :)

avatar image TornadoStorm Dec 05 '17 at 09:33 AM

Me too! I also need to know how to change the gamemode manually. Do I simply spawn a gamemode blueprint or something?

avatar image zerophase Nov 19 '16 at 04:35 AM

How can I change the gamemode manually?

avatar image Dc43 Jun 30 '17 at 02:43 PM

I too need to know how can I change the game mode manually??

(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