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

Get help using Construct 2

Post » Mon Apr 04, 2016 5:58 am

Here is a capx of what I am working on.

@@https://drive.google.com/open?id=0B0psFoxYWKO0Vk9VMXRyS3BUeHM

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.
B
13
S
4
G
1
Posts: 31
Reputation: 1,439

Post » Mon Apr 04, 2016 12:55 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Apr 04, 2016 1:36 pm

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
B
13
S
4
G
1
Posts: 31
Reputation: 1,439

Post » Mon Apr 04, 2016 2:19 pm

99Instances2Go wrote: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.
B
13
S
4
G
1
Posts: 31
Reputation: 1,439

Post » Mon Apr 04, 2016 2:55 pm

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

And read to manual about variables.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Apr 04, 2016 4:28 pm

99Instances2Go wrote: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

And read to manual about variables.


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

https://drive.google.com/open?id=0B0psF ... 0JrOGRFeFk

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
B
13
S
4
G
1
Posts: 31
Reputation: 1,439

Post » Mon Apr 04, 2016 9:06 pm

https://
drive.google.com/open?id=0B1SSuCVV8v74aFdjWXRwUEtMaFE
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 23 guests