GML Visual Door Button Needs to change the instance of the Door rather than itself.

J

Jcraft2000

Guest
I am trying to make a button that opens/closes a door and so it needs to be able to change the instance of that door into either open or close, but unlike in Game Maker 1, Game Maker 2's DnD doesn't seem to have an option for that within the change instance tool. Any tips?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
I dont know the equivalent in D&D
but you just need a With statement
GML:
with(obj_door_closed)
{
    instance_change(obj_door_open, perf);
}
preferably you'd put that in the code that runs when the button is pressed
 
J

Jcraft2000

Guest
I may have found a work around but this is not confirmed yet
 
J

Jcraft2000

Guest
I dont know the equivalent in D&D
but you just need a With statement
GML:
with(obj_door_closed)
{
    instance_change(obj_door_open, perf);
}
Thank You, if my work around does not end up working I'll try this
 

Nidoking

Member
You would probably want to store the instance ID of the door (as determined in the Room Editor) as a variable in the button instance and use that.
 

Slyddar

Member
but unlike in Game Maker 1, Game Maker 2's DnD doesn't seem to have an option for that within the change instance tool. Any tips?
It's called the "Apply to" code block, and can be used to change the variables in another instance. If you get the id of the door, you can use "Apply to" to then change values of that instance. In this tutorial video around the 5:00 minute mark, I show how to use it.
 
Top