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?
Is there a "isBodyInContact" sort of function?
- mallyone
- Posts: 9
- Joined: Mon Apr 26, 2010 8:31 am
- Contact:
- mallyone
- Posts: 9
- Joined: Mon Apr 26, 2010 8:31 am
- Contact:
Re: Is there a "isBodyInContact" sort of function?
Just found this thread:
http://www.slembcke.net/forums/viewtopi ... it=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...
http://www.slembcke.net/forums/viewtopi ... it=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...
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Is there a "isBodyInContact" sort of function?
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.
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 90
- Joined: Tue Aug 04, 2009 9:53 am
- Contact:
Re: Is there a "isBodyInContact" sort of function?
When I added this functionality to the SpaceManager project, I stumbled across this thread:
http://www.slembcke.net/forums/viewtopi ... ence#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.)
http://www.slembcke.net/forums/viewtopi ... ence#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.)
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Is there a "isBodyInContact" sort of function?
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
- mallyone
- Posts: 9
- Joined: Mon Apr 26, 2010 8:31 am
- Contact:
Re: Is there a "isBodyInContact" sort of function?
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...
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...
Who is online
Users browsing this forum: No registered users and 18 guests