T
Toldo171
Guest
Hello everybody,
I am new to GameMaker. I have been programming a management/card game for the past 2 months, and right now I have an issue that I cannot solve by myself. That is why I need your help.
What I am trying to do
It is very simple. I want my hero to switch room when he collides with a door. I have:
Inside obj_door, I have a create event and a collision event with obj_hero :
Create event
var targetRoom = 0;
var x_target = 0;
var y_target = 0;
Collision event
room_ goto(targetRoom);
obj_Hero.x = x_target;
obj_Hero.y = y_target;
Then, inside the door instance of each room, I set up the following values:
rm_House door instance
targetRoom = rm_Office;
x_target = 1024;
y_target = 670;
rm_Office door instance
targetRoom = rm_House;
x_target = 800;
y_target = 600;
What it does ingame
The switching room thing works, but my hero is not setup at the right coordinates, instead, he is set up at random coordinates on the top left of the screen. For example, x=-16 y = 254, or x=6 y=211…
Notes
My hero obj_hero is persistent.
I only put an obj_hero instance in the first room, not in the second room.
When the random coordinates are both positives, I can see my hero on the top left on the screen, and I can control it, which means it is not a layer issue.
When I run the game in debugging mode, the new coordinates of my obj_hero are changed to x=1024 y=670 when I hit the door, but only for 1 frame. Then I go step by step, and all of a sudden the coordinates changes to random numbers before the displaying of the other room.
The coordinates are random, but always in the same range of values. For example, x is always between -15 and 10.
Do you have any idea of what is going on?
Thank you very much for your help.
I am new to GameMaker. I have been programming a management/card game for the past 2 months, and right now I have an issue that I cannot solve by myself. That is why I need your help.
What I am trying to do
It is very simple. I want my hero to switch room when he collides with a door. I have:
- My hero obj_Hero
- My doors obj_Door
- 2 rooms, rm_House and rm_Office
Inside obj_door, I have a create event and a collision event with obj_hero :
Create event
var targetRoom = 0;
var x_target = 0;
var y_target = 0;
Collision event
room_ goto(targetRoom);
obj_Hero.x = x_target;
obj_Hero.y = y_target;
Then, inside the door instance of each room, I set up the following values:
rm_House door instance
targetRoom = rm_Office;
x_target = 1024;
y_target = 670;
rm_Office door instance
targetRoom = rm_House;
x_target = 800;
y_target = 600;
What it does ingame
The switching room thing works, but my hero is not setup at the right coordinates, instead, he is set up at random coordinates on the top left of the screen. For example, x=-16 y = 254, or x=6 y=211…
Notes
My hero obj_hero is persistent.
I only put an obj_hero instance in the first room, not in the second room.
When the random coordinates are both positives, I can see my hero on the top left on the screen, and I can control it, which means it is not a layer issue.
When I run the game in debugging mode, the new coordinates of my obj_hero are changed to x=1024 y=670 when I hit the door, but only for 1 frame. Then I go step by step, and all of a sudden the coordinates changes to random numbers before the displaying of the other room.
The coordinates are random, but always in the same range of values. For example, x is always between -15 and 10.
Do you have any idea of what is going on?
Thank you very much for your help.