Lately I am having some issues with implementing a Room transition Mechanic and it is working fine, it is able to transition from room to room, however when it involves multiple rooms it goes completely haywire.
The problem began like this: I have created a swamp level and a small wooden cabin, when you go to the cabin door you transition to the cabin room. When move further down to the end of the room you transition to another portion of the swamp, instead the player transitions to the cabin even though the creation codes tells the instance to specifically transition to the other room. I tried many other methods such as variable definitions or even global variables but issue is still remains the same.
Instance Creation code:
Step Event:
Collision to Player:
Room Transition Scripts:
The problem began like this: I have created a swamp level and a small wooden cabin, when you go to the cabin door you transition to the cabin room. When move further down to the end of the room you transition to another portion of the swamp, instead the player transitions to the cabin even though the creation codes tells the instance to specifically transition to the other room. I tried many other methods such as variable definitions or even global variables but issue is still remains the same.
Instance Creation code:
GML:
//Target Room Coordinates
target_r = rm_SwapOne
//X & Y Coordinates
target_x = 135;
target_y = 150;
GML:
//Transition
if place_meeting(x,y,obj_player) && keyboard_check_pressed(ord("Z")){
if !instance_exists(obj_fade)
{
//Create Fade
instance_create_layer(x, y,"Instances",obj_fade);
}
}
//Transfer Coordinates
if instance_exists(obj_fade) && (obj_fade.state = 1)
{
room_goto(target_r);
obj_player.x = (target_x);
obj_player.y = (target_y);
}
GML:
//Change Room
if (keyboard_check_pressed(ord("Z")) && !instance_exists(obj_fade)){
//Target Room
var _targetRoom = room;
if (_targetRoom == room) _targetRoom = target_r; obj_player.x = target_x; obj_player.y = target_y;
//Fade
scr_roomTransition(_targetRoom , 30, c_black);
}
GML:
///@description
/// @arg room
/// @arg duration
/// @arg color
//Args
var _room = argument0;
var _dur = argument1;
var _color = argument2;
//Create
var _inst = instance_create_depth(0, 0, 0, obj_fade);
//Set Properties
with (_inst){
targetRoom = _room;
duration = _dur;
color = _color;
}