Disappearing and Reappearing Obstacles!

R

Richard Nava

Guest
Hello GM Community!

I am trying to create disappearing and reappearing obstacles for my game, but I have no clue how to make them reappear after I destroy the object.

Anyone know how to solve this?

Thanks!
 
T

Ting_Thing

Guest
If you destroy an instance, you cannot make it reappear. But you can create a new one. The command is instance_create(x,y,object). There's also a Drag and Drop icon for that.

Instead of destroying an instance, you could just make it temporarily not visible. There's a built-in variable called "visible" which you can set to true or false. Note that if you make something invisible, it will still behave normally, even though you can't see it.

You could also temporarily deactivate the object. But I think one of the two options above will serve your purpose. Good luck!
 
Ok, first, I just want to point out that there are alternatives to destroying an instance. You can deactivate it, and then reactivate it. You can move it to another position, and then back again. If you simply move it someplace outisde of the room boundaries wthen it is supposed to disappear, you can have the object move itself back to where it was at the end of an alarm.
 
R

Richard Nava

Guest
Im trying to make it where you can walk over the obstacle while it isnt visible, but will kill you if you walk over it while it is (like disappearing and reappearing spikes). Im a complete noob to GML so its been rough.

Is there a command to make the object 'teleport' to outside the room?
 
you could just add a huge value to its x or y coordinate...

x += 10000000;

and then when you want to move it back, subtract the same amount from its x component

x -= 10000000;

or record where it is at the time it disappears

old_x = x;
old_y = y;
x = 1000000000;

and then return it to that position with

x = old_x;
y = old_y;

keep in mind if you do this it will continue to execute whatever other code it has in its events

it might be a better idea to deactivate it and then reactivate it, but then you'd need a different object to keep track of which obstacles are currently disappeared.
 
K

Kululu17

Guest
I would second the idea that you can make it visible or not, and you can even make it collide or not... but one thing to watch for (not that I want to make things more complicated!) is what happens if it reappears when the player is there. It can cause the player to get "stuck". If this is the effect you are looking for, fine, but otherwise you might want to include some code to make sure it doesn't reappear when the player is there...
 
R

Richard Nava

Guest
Is there commands to 'deactivate and reactivate'? I see it in the documentation but im unsure how to apply it to my object :(
 
Top