# How do I keep a block from going into a solid?

0 Favourites
• 7 posts
• Here is a capx of what I am working on.

I have been trying to figure out why Player2 Blocks will go through solids for about 1/4 of its height. I am using the platform behavior for both Player and Player2 blocks(for the gravity). They both have the same size collision box but the Player box does exactly what I would expect when it hits a solid, no matter the speed. But on the other hand the Player2 box will sink into the solids, the faster the fall the more pronounced but even at slow speeds it sinks in slightly.

Any thoughts as to why this is happening? I have no idea, and haven't come close to figuring out a work around.

Aaron

edit: also if the capx is to big and the events are to convoluted due to bad coding please let me know and Ill try to recreate problem at a much smaller scale.

• It does not fall through the solids. It gets pushed through the solids by the move and rotate commands.

Would you use the controls that go with the behaviour (in your case the platform controls) this would not happen. Since you have the 'default controls' set on 'no' that would be the 'simulate actions'. The Platform controls will not push an object through the solids, because, well, they belong to the behaviour. Thats how its made, and why its made for.

A car that automaticaly stops for obstacles, (thats a behaviour: it scans the road and will use its own brakes) will get pushed through by a big truck behind it, because the truck does not belong to te cars system.

So, in youre case, the Platform is not usefull. Since you want 'grid movements', And the Platform is not suitable for that. Just because you cant use its controls, there is no gain in using the behaviour.

I suggest:

1/ Dont use the Platform.

2/ Code youre own falling movement (change Y every tick, dt corrected).

3/ When a key pressed, first store the current position of the players in variables.

4/ Then make the move or the rotation.

5/ Then check if that move is possible by checking overlaps with walls and allready fallen blocks.

6/ If the move is not possible, fall back to the stored position.

7/ Spawning will happen on the collisions.

• Thanks a bunch. I figured that I was going to need to recode the physics because the platform behavior was me just trying to hack together by playing with behaviors. Thanks a bunch for the direction that I need look into. I learn more everyday.

Also btw. I knew that upon rotation or even movement by pixel that the object would go through the solids. I was meaning something different. If you rotate the blocks and lead with block 2 and let it land first on the ground or on blocks then it sinks into the object. (Not that it matters now as I am going to try and redo my falling logic)

Aaron

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 3/ When a key pressed, first store the current position of the players in variables.

4/ Then make the move or the rotation.

5/ Then check if that move is possible by checking overlaps with walls and allready fallen blocks.

6/ If the move is not possible, fall back to the stored position.

7/ Spawning will happen on the collisions.

Is there anyway you could elaborate a bit more on saving position of player? Is it under a system or a behavior i need to add? Sorry for the questions, and i am still looking around the web and having trouble even starting this process.

I was able to figure out the falling logic very easily, so thanks again for the help.

• add a Global Variable xx = 0 (number)

add a Global Variable yy = 0 (number)

Direct after a key trigger condition: (or every tick, as you wish)

add action > system > set value xx to player.X

add action > system > set value yy to player.Y

Then make the move as you allready do

Then

add condition > player is overlapping walls (because that would be an illegal move)

add action > player set postion to x = xx / y = yy

• add a Global Variable xx = 0 (number)

add a Global Variable yy = 0 (number)

Direct after a key trigger condition: (or every tick, as you wish)

add action > system > set value xx to player.X

add action > system > set value yy to player.Y

Then make the move as you allready do

Then

add condition > player is overlapping walls (because that would be an illegal move)

add action > player set postion to x = xx / y = yy

Had a long reply all typed up and then hit submit and had to do a recaptcha.... lost the post. so.

Here is my capx attempting at my understanding of your last post. I think that it is working the problem is that it is updating every tic, so when it hits the wall it sends itself to that spot(in the wall) I tried 1 per second but it was way to slow, but it showed it actually moving and not going into the wall.

I believe I misunderstood something very crucial. Also i used the same type of controls, I thought that is what you meant in your post. If not i apologize.

Thanks a million for your time so far and all the help you have already given me.

Aaron

edit: in my capx i accidentally left the Object GreenP with the behavior Solid. It was me just testing and playing around, you can turn it off, delete behavior if you want/need

• https://