• 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!

Legacy GM Collision check inside a collision?

N

NeonBits

Guest
Yes but why "instance_place" inside a "place_free"? if it's free, no collision, the code can run, but then we add the id from a collision? or am I supposed to understand free from any ID?
 
It's checking if the instance at the position x+1 is marked as solid. It's a little bit weird to do it this way, but that's what it's doing.
 
N

NeonBits

Guest
is marked as solid or if it's colliding; where "solid" appears in that line? I'm beginning to think all this is a joke...
 
Here's what I was thinking with this code:

Code:
collisionA = instance_place(x + 1, y, all);
This captures the id of the instance directly to the right of us.

Code:
if(  place_free  (x + 1,  collisionA.bbox_bottom + ( y - bbox_top ))  )
This is checking whether the space *underneath* the instance to the right of us (collisionA) is free or not.

That's what I want, anyway! This code works fine when one of my wall objects is by itself, but as soon as I put them near one another, weird things stop happening, and the check doesn't work, so I'm doing something wrong here.
 
Ok, I read it wrong to begin with. instance_place returns the instance ID of whatever is at position x+1. That instance ID is stored in collisionA, which is then used to check if there is a solid in the position that looks like the bottom of collisionA+the top of the bounding box of the instance doing the calling in the first place. It's hard to get a handle on the original purpose of the code when all there is is this snippet. But I'm pretty sure it's doing what I just described. It's not a joke, but it's certainly a weird line when it's all on it's own and it might be incorrectly coded. What is the context around the code?
 
N

NeonBits

Guest
as soon as I put them near one another, weird things stop happening, and the check doesn't work, so I'm doing something wrong here.
So weird things stop happening because you're doing something wrong... for me it's !(bad)... then it's good...
If nothing weird is happening then everything is on rail! Joke. I get it, you're doing something wrong.

I still don't get the solid...

And I think I should stop thinking that people know what they're doing when they are here resquesting help >.<

Wouldn't it better to write
Code:
if  (place_free  (x + 1,  y) )
{   with (all)
    {    if  (instance_place(x, obj_.bbox_bottom + ( y - bbox_top ))
         {
                // anything
         }
    }
}
 
Last edited by a moderator:
Ok, I read it wrong to begin with. instance_place returns the instance ID of whatever is at position x+1. That instance ID is stored in collisionA, which is then used to check if there is a solid in the position that looks like the bottom of collisionA+the top of the bounding box of the instance doing the calling in the first place. It's hard to get a handle on the original purpose of the code when all there is is this snippet. But I'm pretty sure it's doing what I just described. It's not a joke, but it's certainly a weird line when it's all on it's own and it might be incorrectly coded. What is the context around the code?
I'm trying to make sure that not only is there free space directly below collisionA, but that it's also a big enough space for the player to pass through. :x
Because if there's free space and it's big enough for the player to pass through, the next step is to start sliding the character toward the hole, to allow for "smooth" corners. If there's space below collisionA, but it's not big enough for the player to fit, there's no reason to slide them toward the hole.
 
And I think I should stop thinking that people know what they're doing when they are here resquesting help >.<
Alright, turns out I knew what I was doing. Check out the other thread, lol. My code was just a badly formatted mess, so I had some if statements nested in the wrong spot like an idiot. All I had to do was move a few curly braces. Problem solved, hahah! Man, I love programming! X'D
 
Top