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 / Box2D Physics

Author
Message
Jimmy 9Toes
15
Years of Service
User Offline
Joined: 24th Nov 2008
Location:
Posted: 21st Nov 2011 21:12
I'm trying to use Box 2D to do asteroid behavior where the rocks bounce off of each other. I'm assigning a velocity to the rocks and they're bouncing off of each othet just fine. But they eventually slow down to a crawl.

Is there a way to keep them moving at the same speed constantly? To possibly turn of this friction?

Yes THEE Jimmy9Toes
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Nov 2011 11:48 Edited at: 22nd Nov 2011 11:50
Are you storing the rock's velocity and direction as a vector or as x y and z values? Store them as a vector (a vector is a direction (like 0-360 degrees, and a speed) and don't allow the speed variable to change.


Euphoria
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: United Kingdom
Posted: 22nd Nov 2011 12:33
Not an expert but have you tried:

SetSpritePhysicsFriction( asteroid, 0 )
SetSpritePhysicsDamping( asteroid, 0 )

You might also want to look into the Restitution value as that affects its 'bounce' factor.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Nov 2011 15:53
Damping should be enough.

No need to edit friction as you probably want them to have at least a standard amount of friction for when they hit each other so they can set each other spinning.

Jimmy 9Toes
15
Years of Service
User Offline
Joined: 24th Nov 2008
Location:
Posted: 22nd Nov 2011 16:54
Thanks for all the tips. I'll give them a try.

Yes THEE Jimmy9Toes
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 23rd Nov 2011 13:27
Oh duh, should've realized you weren't doing physics yourself ^.^


Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Nov 2011 23:26
A restitution value of 1 means objects will not lose any energy in a collision. Interestingly values greater than 1 will make objects gain energy though collisions which can lead to some fun, if somewhat unstable, simulations.

Login to post a reply

Server time is: 2024-05-06 10:25:08
Your offset time is: 2024-05-06 10:25:08