Need help making a door solid after block is moved off pressure point please?

B

BobTheGamer96

Guest
Hi, I'n relatively new to game maker and I am working on a top down sokoban project. I want to make a door that remains locked until a block is placed on top of a 'pressure point'. I have got this to work to and extent; the door is solid until a block is placed on the pressure point, I the used the instance dectivate command and faded out the door, i can then go through the door. This all works fine but I want the door to fade back in and become solid again ,so that room is locked, when the block is removed from the pressure point.
Any help would be greatly appreciated
Thanks
 
Last edited by a moderator:
Hi, I'n relatively new to game maker and I am working on a top down sokoban project. I want to make a door that remains locked until a block is placed on top of a 'pressure point'. I have got this to work to and extent; the door is solid until a block is placed on the pressure point, I the used the instance destroy command and faded out the door, i can then go through the door. This all works fine but I want the door to fade back in and become solid again ,so that room is locked, when the block is removed from the pressure point.
Any help would be greatly appreciated
Thanks
In your pressure point object,
Instead of instance_destroy, use
instance_deactivate.

Then when the block is not touching the pressure point,
instance_activate the door.

This should all go in your pressure point object because when the door is inactive, it cannot run code
 
B

BobTheGamer96

Guest
In your pressure point object,
Instead of instance_destroy, use
instance_deactivate.

Then when the block is not touching the pressure point,
instance_activate the door.

This should all go in your pressure point object because when the door is inactive, it cannot run code
I did try this, i replaced the instance_destroy with instance_deactivate and it still worked. I am having no luck with instance_activate when the create is moved off the 'key'. Can you take a look at this code and see what you think please?Step Event of obj_key.PNG
 
I did try this, i replaced the instance_destroy with instance_deactivate and it still worked. I am having no luck with instance_activate when the create is moved off the 'key'. Can you take a look at this code and see what you think please?View attachment 19188
You didn't change the image alpha back
Since you only deactivated the object, the create event won't run again, so image_alpha will stay 0.
I think that it might be working but you just can't see the door.
Set image_alpha to 1 when you activate it and see if that fixes it
 
B

BobTheGamer96

Guest
You didn't change the image alpha back
Since you only deactivated the object, the create event won't run again, so image_alpha will stay 0.
I think that it might be working but you just can't see the door.
Set image_alpha to 1 when you activate it and see if that fixes it
No i'ts not working, I think what you said about the create event not running is correct, is there anywhere else I could set global.locked to true?
 
create event of obj_key
There's the problem
Your global.locked never gets reset when the block is taken off.

This is what I suggest. Instead of using collision event, check for collision in step event with place_meeting

Above the code in the picture you showed:

global.locked = !place_meeting(x,y,obj_crate)

So if the crate ever gets off the key, then global.locked will be true again
 

EvanSki

Raccoon Jam Host
Funny enough I just made this system for my game, If you want to take a look at my code for it pm me and I'll be happy to share, Good luck on solving your issue
 
B

BobTheGamer96

Guest
There's the problem
Your global.locked never gets reset when the block is taken off.

This is what I suggest. Instead of using collision event, check for collision in step event with place_meeting

Above the code in the picture you showed:

global.locked = !place_meeting(x,y,obj_crate)

So if the crate ever gets off the key, then global.locked will be true again
Thank you so much for helping me i really appreciate it. I have done what you said, maybe I interpreted what you said wrong. HeStep Event of obj_key.PNG error.PNG Step Event of obj_key.PNG re are the images of the code and the error that occurred. Any ideas? Thanks
 
Thank you so much for helping me i really appreciate it. I have done what you said, maybe I interpreted what you said wrong. HeView attachment 19190 View attachment 19191 View attachment 19190 re are the images of the code and the error that occurred. Any ideas? Thanks
Oh I meant only the line

global.locked =!place_meeting(x,y,obj_junk)

Remove the if place_meeting at the beginning.
Also, Tell me if the error still comes because there might be a problem with my line
 
B

BobTheGamer96

Guest
Oh I meant only the line

global.locked =!place_meeting(x,y,obj_junk)

Remove the if place_meeting at the beginning.
Also, Tell me if the error still comes because there might be a problem with my line
The error still persists, although it's different this time. Please see atatchmenterror.PNG Step Event of obj_key.PNG
 
B

BobTheGamer96

Guest
Funny enough I just made this system for my game, If you want to take a look at my code for it pm me and I'll be happy to share, Good luck on solving your issue
Hi, thanks for the offer, i've pm'd you
 
Last edited by a moderator:
B

BobTheGamer96

Guest
It nearly works now. I just get this error when i drive into the door after global.locked = true. I used a collision event in obj_door, and error says it can not compare arguments. I think it is because i put if global.gameover = true. Have you any ideas what I can replace it with so the error does not persist? See code below, sorry some is in DnD. Thankserror.PNG Step Event of obj_key.PNG again
 
B

BobTheGamer96

Guest
Oh wait I didn't notice you changed this,
you do
if (global.locked == false)
Twice
One of them should be true, no?
I'm not quite sure what you mean, I think because global.locked is not set to true or false at the beginning of obj_key step event
 
B

BobTheGamer96

Guest
What is the collision event for, take it out for a second and see if your door is activating and deactivating correctly
When the collision event is taken out the player can go through the door even when it's locked
 
B

BobTheGamer96

Guest
I've fixed it now - It's all working. IN the collision event between the door and the player i changed the variable to if it's equal to !place_meeting(x,y,obj_junk) instead of true. Thank you soooo much for your help i really appreaciated it. I wish you the best of luck with your future Gms projects.
 
I've fixed it now - It's all working. IN the collision event between the door and the player i changed the variable to if it's equal to !place_meeting(x,y,obj_junk) instead of true. Thank you soooo much for your help i really appreaciated it. I wish you the best of luck with your future Gms projects.
Oh ok then, if it's working fine then congrats
Luck on your Gm projects too
 
Top