Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics doing the impossible?

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2013 18:07 Edited at: 5th Dec 2013 18:07
While testing one of the levels in my WIP, I managed to get the player sprite pushed through a solidish wall of other sprites.

When I direct the movement of the sprite and let it go, it will bounce of a wall of sprites like it should.

But if it gets shoved just right by another sprite, it can get pushed through the wall.

The wall is made of a bunch of round images whose circular collision boxes overlap. So it should not be able to get through.

The green/yellow blobby things in the upper left of the image (a snap of the level editor view) are circling about the hazy colored thing (indicated by the white, dotted path). When the player gets mashed just right between one of them and the wall of purple, orange and blue sprites, it gets shoved through. You can see the physics collision boxes around each.

Since I don't want to try to figure out why (totally controlled by the AppGameKit physics engine), I am just going to move the wall.



Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Dec 2013 19:40
Is the wall of circles attached with joints? If so, what kind?

Do you see the circles move as it gets pushed through?

I have noticed with all physics systems, even the most robust of joints still have some elasticity, even to the point of the connection being torn apart if you put enough force on it.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2013 19:59 Edited at: 5th Dec 2013 20:02
The circling objects are not using joints. Originally I had done that, but they were then affected too much when hit. I have code that repositions them each frame. Then they don't go off orbit if collided with.

I think I've removed all joints in order to get the consistency of movement of the things that are supposed to be in certain paths.

The sprite that is getting shoved through the wall is is sitting in the middle of the rainbowy thing at the lower left of the image. The other rainbowy thing is where it is supposed to get to. They are called Emergency Return Wormholes (the story line is explained here).

That is the only sprite that is really driven by the physics engine. In the game, you have different methods to make it move. But all involve heading it somewhere with a certain amount of energy and then the physics engine takes over.

That is why it somehow gets squished the non-moving wall of sprites.

EDIT: The snapshot above doesn't have YeeYee sitting in the entrance Emergency Return Wormhole. Curious? He shows up in all the the other snaps. The entry one is the smaller rainbowy thing with the bigger clear center.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Dec 2013 23:07
Quote: " I have code that repositions them each frame."


That may be the culprit. If you move physics-enabled sprites around with non-physics commands, it gets messy.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2013 03:58
Not really, I have had no issues before.

It is just a case of the forces being squished, I think, and maybe the order in which it applies things, sometimes.

This is the very first time (in lots of different scenarios, ie. game levels and tests) that I have seen this happen.

The poor player sprite gets stuck in a spot and shoved repeatedly by other sprites and eventually gets hit just right that it gets pushed passed sprites that are just sitting there.

In another level, a similar situation occurs, but the sprites being pushed against are actually further apart. And the player sprite doesn't get squished out.

I'm not sweating it. Not all systems are perfect.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Dec 2013 09:42
This can happen even with sprites that are not positioned every frame and is a limitation of Box2D. You can reduce the effect by changing the scale using setPhysicsScale but if a sprite is pushed hard enough it will go through because (as in the real world) if a great enough force is exerted on an object it will pass between two other objects even if they are connected. Even a camel can pass through the eye of a needle if enough force is exerted upon it.

One real world application of this is in the use of copper in demolition where copper cones (and other shapes) are used to direct the force of an explosive to cut through steel. Ordinarily you would say that copper cannot cut through steel but I've seen copper fired through up to a meter of solid steel

Another is in the use of water cutting machines that cut through steel and other metals (with aggregates to increase friction).

Basically you need to play with your physics scale but this might mean changing a whole heap of hard coded values for force etc.

oct(31) = dec(25)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Dec 2013 09:45
Quote: "I'm not sweating it. Not all systems are perfect."


Yes, but we all love a good challenge around here!

My other thought would be about the circles overlapping. I don't know how you've achieved it (apart from them being in different non-interacting groups?) but they are already fighting to get away from each other, they can't occupy the same space in the physical world. Have you got a constant explosion going on that you correct every loop that you are correcting manually?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 6th Dec 2013 14:48 Edited at: 6th Dec 2013 14:48
Physics systems often use the quicker stepping method of collision detection. The collisions are basically calculated depending on what the current frame looks like, an entity which is small enough and moving fast enough can tunnel through walls etc.

That may not be what is happening here. If it is then there is usually on option for continuous collision detection. This means a line is drawn between last position and current position and collision is detected in that way, so a fast moving bullet will not tunnel through where it is not supposed to. It's slower but is required in certain situations.

Take a look to see if agk has anything like that, if not, take a look to see if Box2D has anything like that(I would bet my life it does).

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th Dec 2013 15:06
Quote: " If it is then there is usually on option for continuous collision detection."

Ah, that explains SetSpritePhysicsIsBullet(), I always wondered what that did differently.

Always learning
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2013 15:49
baxslash, I think you have the right answer to the why.

BatVink, the wavy lines of sprites aren't moving. They are fixed in position.

Matty H., the player sprite that is getting shoved through the wall is larger than the wall sprites it is being pushed through. But it is something to remember when designing other levels and using sprites sized larger than the player.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Dec 2013 15:56
It seems we were wrong to think outside teh box this time, we should have been thinking inside the Box(2D)

Terrible pun but I had to say it!

Once again today has been a school day, and learnt a little bit more.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 6th Dec 2013 15:57
Quote: "Matty H., the player sprite that is getting shoved through the wall is larger than the wall sprites it is being pushed through. But it is something to remember when designing other levels and using sprites sized larger than the player."


You should try the 'bullet' command anyway, the walls are pretty thin which is also a contributor to possible tunnelling. Good to know that command exists, thanks Marl

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2013 16:07
I don't think I need to go the 'bullet' route. It would impact performance on slower devices. And, for my case anyway, I just have to build my levels such that the interaction I saw doesn't occur. Simply, make sure there is enough room for the player to not get irretrievably stuck.

But, I can see using it in another type of game. I hate it when things give me new ideas for projects when I have so many already on my plate (not to mention moving to Alaska and starting a new job). But I like getting inspirations because it means my brain is working and getting excited.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Dec 2013 16:57
Actually you should only need the bullet command on your player sprite I would have thought and it might actually help

oct(31) = dec(25)
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th Dec 2013 18:48 Edited at: 6th Dec 2013 18:49


Sorry, couldn't resist

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2013 20:06
baxslash, it might. But I don't think it goes that fast (except in one situation and I haven't had issues with that). I have the timing working well on it now. At this stage of the WIP, I'm not messing with it. It would mean retesting all the existing levels in all the modes and platforms.

Marl, totally appropriate.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-11-24 23:21:18
Your offset time is: 2024-11-24 23:21:18