[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Is there a "isBodyInContact" sort of function?

Is there a "isBodyInContact" sort of function?

Official forum for the .

Is there a "isBodyInContact" sort of function?

Postby mallyone » Sat May 01, 2010 3:06 pm

I'm trying to relearn c and make the little ball from the simple.c jump. I have use the body slew function, but jumps are occuring from the air as well as from the ground. I was thinking there might be a "ismakingcontact(space, body). I have a collision handler setup, but it seems like overkill in this instance?

Anyone have some help for a noob?
User avatar
mallyone
 
Posts: 9
Joined: Mon Apr 26, 2010 8:31 am

Re: Is there a "isBodyInContact" sort of function?

Postby mallyone » Sun May 02, 2010 8:28 am

Just found this thread:

viewtopic.php?f=1&t=306&start=0&st=0&sk=t&sd=a&hilit=jumping

that's the approach I was trying to take, set a global isjumping variable and set begin and separate arbators which just flick the "isjumping" variable back and forth.

Not my ideal solution and not working 100% but oh well.

Are arbators cpu intensive? I was pretty amazed that I had between 1 and 5% cpu usage for my simple scene. That whole tick system is pretty cool :)

Anyways, back to my question, does anyone know a simple jumping algorithm? Is the bool arbitor the best way to go?

mallyone...
User avatar
mallyone
 
Posts: 9
Joined: Mon Apr 26, 2010 8:31 am

Re: Is there a "isBodyInContact" sort of function?

Postby slembcke » Sun May 02, 2010 12:12 pm

Arbiters are only as expensive as the code you put in the callbacks. Chipmunk already has to do a lot of processing for each collision in the scene, so you would have to have a lot of code running in your callbacks to make it much slower.

Also, don't use a boolean, use a counter. Say you touch the floor then a wall, and then move away from the wall. You would set your bool to true, then set it to true again, then set it to false when moving away from the wall. Not what you want. By counting the number of objects you are touching you can always be sure that you are in the air when the count is 0.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Is there a "isBodyInContact" sort of function?

Postby mobilebros » Sun May 02, 2010 9:52 pm

When I added this functionality to the SpaceManager project, I stumbled across this thread:

viewtopic.php?f=1&t=387&p=1766&hilit=persistence#p1766

I usually set the cp_contact_persistence global to 3 or more when using the algorithm described there and it works great (of course you'll find out that you can jump off anything that's touching "you", walls, ceiling, etc.)
mobilebros
 
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am

Re: Is there a "isBodyInContact" sort of function?

Postby slembcke » Mon May 03, 2010 10:02 am

There are a bunch of ways of solving that though. You can check normals, tag floors with a special collision type, etc. The player controls demo records the normal of the things that it's touching so you can jump off of walls at an angle.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Is there a "isBodyInContact" sort of function?

Postby mallyone » Wed May 05, 2010 7:26 am

Thanks for the replies, knowing that the abitors themselves are not expensive is very useful. I started to use an int for collision counts but was still having difficulty, although it does seem like the right way to go.

I'm going to go digging a little deeper into that thread you posted mobilebros, they are are many ways to crack this egg :).

I'm onto two wheels joined by a damped spring as my testing player right now. Trying to clamp down on velocity using simple motors etc... I've always loved joints, but now I love them even more! ;)


m...
User avatar
mallyone
 
Posts: 9
Joined: Mon Apr 26, 2010 8:31 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest