I’ve posted a few topics onto this website already, so I’ll try and make this brief and concise as possible.
I have these 2 blocks. They can be pushed by the player, and if there is no floor under them, they fall.
I want these blocks to be able to collide, as in, not being able to be pushed through each other, and, if one were to fall onto another, it would land on it as if it were floor.
In the image below, the two blocks are in each other.
Use Physics Behavior. Dynamic for blocks and Static for floor. And TopDown Behavior for blocks.
I agree with Zutty, that should solve your issues.
I really, really, really do not want to touch the physics behavior.
When physics objects fall onto each other, they kind of sink into it and then rise back up, like they’re soft or something. Not to mention, the collision mask you set in the behavior window doesn’t actually match up correctly when you run the game. Physics objects float like 2 ish pixels above things.
I understand why you can’t do this, but I really wish you could upload videos onto here, cause then I could totally show you what I mean.
It’s a matter of adjustments (Density, Friction…). I think it’s the easiest way to achieve what you want. Do not change the collision mask but the shape size instead to avoid the gaps. Make it 1px less than the sprite size (height and width)
Your suggestion is great, however, I will show you something real quick:
Even when following your instructions, this still happens. I need the blocks to align and stand on top of each other without any gaps or anything.
Also, all the other tiny gripes I’ve had with the physics behavior aren’t just a matter of adjusting numbers or anything, it’s just something that happens, especially when a lot of them are stacked or falling onto each other.
I’ll work on it some more, I’ll probably find a solution. Thanks for the suggestion though.
As I told you, change the shape size of your block.
i.e. if your sprite is 60x60px, change the size of the shape to 59 like in this pic and test it.
I did. I said I followed your instructions.
My sprite is 16*16. I used width 15 and height 15.
Are you still having a gap?
You could use a collision object. This is essentially an object (sprite) that’s the same shape and size as the box, but is hidden. Place the collision object in the same place as the box, and use the sticker extension to joint it to the box object.
Give the box and it’s linked collision object the id (in the form of an object variable). You can then check for collision between box and collision object where their ids do not match. Then move the box away from the collision object. You may need to add some conditions to the event with this action to check the box is above or being pushed.
I mean I guess that would work, it’s super backwards and weird though.
I dunno, it’s something, I’ll give it a try. I don’t think I need to use an extension, I can just use the aforementioned ID variable to set the box position to the collision position.
I actually already made a thing that gives enemies unique IDs so this won’t be too different from what I’m used to.