GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Chikai Mar 24, 2020 @ 3:45pm
Door collision not working | Change child- & parent objects code-wise
Hey devs!

Game concept
On my topdown zombie game I'm trying to create doors for the players to open. Ones the doors are open there should be no collision, ones the doors are closed there should be collisions. I'm stuck on this because I can't change object parents and childs code-wise.

How it works:
The player collides with oSolid (and child-objects of oSolid). oDoor is oSolid except if it's open (a variable shows if it's open or closed).

The problem:
I want to change the child-objects of oSolid. When the door is open it should not be a child of oSolid, when it's closed it should be a child object. That way the player collides with the door if it's closed and ones it's open the player can pass through. Unfortunately I can't find a way to do this.
Do you guys know how I can fix this or if there's a better way to do this?

Thanks in advance! :steamhappy:
~ Jochum
Last edited by Chikai; Mar 24, 2020 @ 3:45pm
< >
Showing 1-2 of 2 comments
Chikai Mar 24, 2020 @ 3:47pm 
Here is the code of the door object (parented to oSolid):

[Create]
image_speed = 0;
price = 1;


[Step]
//Change image based on variable
if (state == 0) {
image_index = 0;
} else {
image_index = 1;
}


[Left Pressed]
//Change state on click
if (price <= global.money) {
if (state == 0) {
global.money -= price;
state = 1;
}}
Last edited by Chikai; Mar 24, 2020 @ 3:49pm
maras Mar 24, 2020 @ 4:00pm 
You can't change parents ingame. Change the door instead
Once you collide with a door check if the door is open. If it's closed collide with it the same way as with oSolid
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Mar 24, 2020 @ 3:45pm
Posts: 2