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 / AGK Tier 1 - Box2D Physics

Author
Message
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 6th May 2016 17:44
Have their been any updates recently (last 12 months) on Box2D physics at all?

I thought I'd revisit an old project that I dumped because of a particular issue, tried again using latest AppGameKit and it's still the same. Problem in a nutshell is that objects colliding with other objects at shallow angles don't rebound at a shallow angle, they just slide off the object. Anybody know a way to work around this?
"It is said that your life flashes before your eyes just before you die. That is true, it's called Life.”
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th May 2016 07:39
Have you got any code to show the configuration? It could be that you need to adjust friction, restitution, mass and gravity to get the effect you want. It is also very dependent on the physics scale you use.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 7th May 2016 10:40
Cheers BatVink, I have been playing with those variables but I can't seem to make it behave better (though I can make it behave worse!). I'll put something together...
"It is said that your life flashes before your eyes just before you die. That is true, it's called Life.”
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 7th May 2016 11:58
Here's a small sample to show the "issue".

"It is said that your life flashes before your eyes just before you die. That is true, it's called Life.”
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th May 2016 12:22
I would be tempted to say there is some kind of bug or inaccuracy here. I can't get the ball to "unstick" from the wall once it hits it. I is as if it has made a rounding error somehow and can't reverse the direction.
I tried it hitting all 4 walls but they all experience the same problem. I changed all of the parameters without success.
The only odd parameter you have it the mass, which seems very heavy. But changing it doesn't solve the problem anyway.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 7th May 2016 20:51
Yeah, sorry, was playing around with the mass, forgot to change it back.

Thanks for looking at it anyway. Any chance Paul could take a look I wonder? Is there a procedure to follow for reporting issues?
"It is said that your life flashes before your eyes just before you die. That is true, it's called Life.”
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th May 2016 16:45
It looks like Box2D has a minimum velocity for elastic collisions of 1 unit per second. Since your physics scale is 0.2 this means that if GetSpritePhysicsVelocityX returns below 5 then it will not bounce. You can work around this by adjusting your physics scale, the following seems to work
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 16th May 2016 12:49
I appreciate the response Paul, thank you. Useful information too.
I'm still struggling with it in my main project even though I've used the same config as the example but it could be down to me missing something. I'll work further on it.
"It is said that your life flashes before your eyes just before you die. That is true, it's called Life.”

Login to post a reply

Server time is: 2024-11-25 08:53:21
Your offset time is: 2024-11-25 08:53:21