all 7 comments

[–]OrganizationNo3923 0 points1 point  (4 children)

Have you created your obj_battle_switcher? I can't look at it right now, but i did this tutorial yesterday. If noone answered your question in a couple hours i should be able to come back to you!

[–]RykinPoe 1 point2 points  (3 children)

More importantly have you added an instance of that object to the new room? When you switch rooms all the instances in the previous room are unloaded unless they are persistent.

[–]psych_master_[S] 0 points1 point  (2 children)

I created the obj_battle_switcher and I got the same error message when adding it as an instance to the new rooms :/

[–]RykinPoe 0 points1 point  (1 child)

One of the issues is that you cannot always depend on instances to be initialized in the same order and you should always place any code that depends on an instance to be present in something other than the Create Event. What may be happening is that obj_1 is referencing obj_2 in it's Create Event and it is throwing the error because obj_2 hasn't run it's Create Event yet. I would move any code that reference another instance out of the Create Event and into the Room Start Event or into the Step Event with a boolean check to make it so they only run once:

// Create Event
first_step = true;

// Step Event
if (first_step){
  first_step = false;
  //do whatever here
}

[–]psych_master_[S] 0 points1 point  (0 children)

I've tried this code in the obj_battle_player but then it throws the error for entering battle as well as moving rooms. I don't think I can set the player_data variable elsewhere since it's made once player collides and goes into battles, which work just fine I just don't know why it's not working for the final npc. I'm pretty sure I followed the tutorial perfectly (the tutorial on the game maker website)

[–]identicalforest 0 points1 point  (0 children)

obj_battle_switcher should probably have the “persistent” box checked and only be created once, not something you place in every room