r/gamemaker•
MedolaR

Need help, Collectible prevents collisions from detecting properly

Help!

I am new to coding, and while following along a Youtube tutorial, I tried adding a collectible(named o_enemy in program). This breaks my characters collision.

I believe it has something to do with how the tutorial has us set up collisions (using a ds_list to store all platform objects to allow falling through certain platforms, then referencing their locations.) Whenever the collectible is added into the room, the character can't jump and if started in the air, they will fall slightly into the ground. However if i remove it from the room, the collisions all work exactly as intended.

Additionally when i tried commenting out all the code in the collectible's code specifically, it pointed to the line of code where it calls for all y speeds of ds_list objects, the error is listed here:

############################################################################################

ERROR in action number 1

of Step Event0 for object oRoyal:

Variable o_enemy.yspd(100021, -2147483648) not set before reading it.

at gml_Object_oRoyal_Step_0 (line 124) - || _listInst.bbox_top + _listInst.yspd <= myFloorPlat.bbox_top + myFloorPlat.yspd

############################################################################################

gml_Object_oRoyal_Step_0 (line 124)

I have been looking through this and editing it for 3 hours with no luck, and I really don't know where to go from here. I have my code for the collisions below, please let me know if you can help!

//Floor Y Collision

//Check for Solid or semi solid platforms under me

var \_clampYspeed = max(0,yspd);

var \_list = ds\_list\_create();

//create DS list to store all objects we run into

var \_array = array\_create(0);

array\_push(\_array,o\_wall,o\_semiSolidWall);

//do the check with variable below, add objects to the list

var \_listSize = instance\_place\_list(x,y+1 +\_clampYspeed + movePlatMaxSpd, \_array, \_list, false); 

//y + 1 (below us)+ clampspeed(only check downward) + movePlatMaxSpd (player stays on platform when fast)

//loop colliding instances, only return if Top is below player

for (var i = 0; i <\_listSize; i++)	  

{

	//get instance of oWall or OSemiSolidWall from list

	var \_listInst = \_list\[| i\];

	//avoid magnetism to ground

		if \_listInst != forgetSemiSolid

	&& (\_listInst.yspd <= yspd || instance\_exists(myFloorPlat) )

	&& ( \_listInst.yspd > 0 || place\_meeting(x, y+1 + \_clampYspeed, \_listInst))

	{

		//return a solid wall for any semi solid walls below player

		if \_listInst.object\_index == o\_wall

		||object\_is\_ancestor(\_listInst.object\_index, o\_wall)

		||floor(bbox\_bottom) <=ceil(\_listInst.bbox\_top - \_listInst.yspd)

		{

//return the "highest" floor

if !instance_exists(myFloorPlat)

|| _listInst.bbox_top + _listInst.yspd <= myFloorPlat.bbox_top + myFloorPlat.yspd

//This is where the crash happens according to gamemaker ^^^

|| _listInst.bbox_top + _listInst.yspd <= bbox_bottom

{

myFloorPlat = _listInst

}

		}

	}

}

//Destroy DS\_list to prevent memory leak

ds\_list\_destroy(\_list);



//one last check to make sure floor is below us



if instance\_exists(myFloorPlat) && !place\_meeting (x, y + movePlatMaxSpd, myFloorPlat)

{

	myFloorPlat = noone;

}



//land on the ground platform if there is one

if instance\_exists(myFloorPlat)

{

	//scoot up wall precisely

	var \_subPixel = 0.5;

//if plat goes under floor, land on floors

	while !place\_meeting(x, y + \_subPixel, myFloorPlat) && !place\_meeting(x, y, o\_wall) {y += \_subPixel;}

	//make sure we dont go below surface of a semisolid

	if myFloorPlat.object\_index	== o\_semiSolidWall || object\_is\_ancestor( myFloorPlat.object\_index, o\_semiSolidWall)

	{

		while place\_meeting(x, y, myFloorPlat) { y-= \_subPixel;	};

	}

	//floor the y variable

	y = floor(y);

	

	//collision with the ground

	yspd = 0

	setOnGround(true); 	

}

Posted Mar 14, 2026, 12:19 AM UTC

13
Loading comments…