• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML [SOLVED] Help Detecting solids

R

roboapple

Guest
Im doing a sideview platformer, trying to get the character to walk up a slope, but the issue im having with the place_free command, if im testing for collisions on the right side of the play, place_free(x+1,y) checks the entire players right side, from top to bottom, so i decided to use the collissions_circle command to detect a small area in front of the player, and have the character move upwards when colliding with an objects, heres what i have so far.

my issue is trying to find a way to get it to detect all solid objects instead off just a single object.
you can see ive tried all.solid and just solid by itself, but it does not work.

//keypress detection
if keyboard_check(vk_left)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x-14-i, y, 1, all.solid, false, true)
{
x-=i;
hdir = -1;
break;
}
}
else if keyboard_check(vk_right)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x+14+i, y, 1, all.solid, false, true)
{
x+=i;
hdir = 1;
break;
}
}
else hdir = 0

//simulated gravity
y += grav * -1;

if place_free(x, y + 1)
{
grav -= .3;
}
else
{
grav = 0;
hspeed = 0
in_air = false;
}

//if colliding with block, move up, thus simulating walking up slope
if !place_free(x, y)
{
y -= 3;
}
 

2Dcube

Member
I'm not sure all.solid is something you can use. "all" means all objects, so even the ones that are not solid.
If you make sure all solid objects have the same parent, something like objParentSolid, you can check all solid objects at once by checking for the parent object.
For example:
Code:
if !collision_circle( x+14+i, y, 1, objParentSolid, false, true) 
{
   //...
}
 
R

roboapple

Guest
I'm not sure all.solid is something you can use. "all" means all objects, so even the ones that are not solid.
If you make sure all solid objects have the same parent, something like objParentSolid, you can check all solid objects at once by checking for the parent object.
For example:
Code:
if !collision_circle( x+14+i, y, 1, objParentSolid, false, true)
{
   //...
}
Awesome, i was thinking parent object, didnt think it was as easy as that to applyit though, thanks for the reply!
 
Top