[EDIT:] see later posts for my new question about a btKinematicCharacterController not sliding against the walls of a static btTriangleMesh.
---------------
Sorry for the stupid question, but what is the difference between a 'dynamic' and 'kinematic' character controller?
I read somewhere that collision with other dynamic objects was not supported with one of these - which one? (or am I barking up the wrong tree, perhaps?)
Also, by 'dynamic' objects in the sentence above, would this refer to objects that have mass (i.e. not 'static'), or is there some other definition that I don't know about?
I think a lot of people have trouble with the character controller but are embarrassed to say that they don't understand it. (or maybe I'm just dumb?:P) If i can discuss it with you learned people then I might be able to come to grips with it easier.
Thank you!!
[SOLVED] kinematic character doesn't slide against walls
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
[SOLVED] kinematic character doesn't slide against walls
Last edited by gennoevus on Sat Oct 16, 2010 5:53 am, edited 2 times in total.
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: Noob question about dynamic/kinematic charactercontrolle
... well I though I was being humble and polite. I guess I'll just have to learn the lot by myself.
Kind of defeats the purpose of having a community though.
Kind of defeats the purpose of having a community though.
-
SteveSegreto
- Posts: 32
- Joined: Sun Sep 12, 2010 10:25 am
Re: Noob question about dynamic/kinematic charactercontrolle
I don't know for sure, but reading the comments in the CharacterDemo, it looks like the "Dynamic" character controller is indeed what you suggested - a rigid body that is moved by forces and can thereby move other rigid bodies with less mass around. So that's the definition of a dynamic character controller (which by the way isn't supported and doesn't compile in the CharacterDemo).
For the remainder of the physics engine, there additionally exists the terms Kinematic, Dynamic, and Static, and they do have something to do with the amount of mass, but also whether the rigid body *NEVER* moves from creation (Static), rigid body has mass and can move around (Dynamic) or rigid body moves irrespective of physical force (i.e. a Kinematic collision object that your program "picks up" and moves so that it is always in front of the player, for instance).
I think the reason nobody answered your question is because it certainly is not a blocking one. You can still use the library without knowing this information and can infer most of this information just by starting to use the library.
For the remainder of the physics engine, there additionally exists the terms Kinematic, Dynamic, and Static, and they do have something to do with the amount of mass, but also whether the rigid body *NEVER* moves from creation (Static), rigid body has mass and can move around (Dynamic) or rigid body moves irrespective of physical force (i.e. a Kinematic collision object that your program "picks up" and moves so that it is always in front of the player, for instance).
I think the reason nobody answered your question is because it certainly is not a blocking one. You can still use the library without knowing this information and can infer most of this information just by starting to use the library.
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: Noob question about dynamic/kinematic charactercontrolle
Fair enough. My understanding of what kinematic meant was slightly off. Now I see that btKinematicCharacterController is not as limited as I thought.SteveSegreto wrote:I think the reason nobody answered your question is because it certainly is not a blocking one. You can still use the library without knowing this information and can infer most of this information just by starting to use the library.
I'll try and implement it now and see what kind of results I get.
Thanks for the reply SteveSegreto.
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: Noob question about dynamic/kinematic charactercontrolle
Hi again,
Well I got it working. I'm walking around my test environment and there doesn't seem to be any major problems going up and down stairs and slopes.
I have two issues though - one is a show stopper and the other is minor.
Problem A) (the show stopper): I get stuck when I walk into walls (i.e. I don't 'slide' against them). This only happens when the character (btCyliderShape) collides against flat walls of a static btTriangleMesh. I slide O.K. against dynamic boxes, etc.
Any ideas on this? I tried changing the btTriangleMesh friction, etc. without any success. I can't see how to change the character's 'friction' if such a thing is possible. Also, I read somewhere that disabling "warmstarting" might fix this but I can't find how to disable this. I did find the m_warmstartingFactor variable, but changing this to different values (0, 1, 2, etc) didn't seem fix the problem.
Problem B) (this one isn't so major): Changing the step height changes the speed that the player falls at! That's O.K., as long as I can manually adjust the gravity just for the player so that he (or she?) falls at roughly the same speed at normal objects.
here are some code snippets: (most of this is straight out of the demo code, please excuse the messiness or my own stuff!)
--------------------
I realise that this forum has more people asking questions than those who can answer those questions! I promise that when I get more knowledgeable about bullet, I'll contribute to the society as much as possible ... in the mean time, please help me get over the first part of the learning curve!
Well I got it working. I'm walking around my test environment and there doesn't seem to be any major problems going up and down stairs and slopes.
I have two issues though - one is a show stopper and the other is minor.
Problem A) (the show stopper): I get stuck when I walk into walls (i.e. I don't 'slide' against them). This only happens when the character (btCyliderShape) collides against flat walls of a static btTriangleMesh. I slide O.K. against dynamic boxes, etc.
Any ideas on this? I tried changing the btTriangleMesh friction, etc. without any success. I can't see how to change the character's 'friction' if such a thing is possible. Also, I read somewhere that disabling "warmstarting" might fix this but I can't find how to disable this. I did find the m_warmstartingFactor variable, but changing this to different values (0, 1, 2, etc) didn't seem fix the problem.
Problem B) (this one isn't so major): Changing the step height changes the speed that the player falls at! That's O.K., as long as I can manually adjust the gravity just for the player so that he (or she?) falls at roughly the same speed at normal objects.
here are some code snippets: (most of this is straight out of the demo code, please excuse the messiness or my own stuff!)
Code: Select all
void bPhysicsInit()
{
broadphase = new btDbvtBroadphase();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
solver = new btSequentialImpulseConstraintSolver;
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
dynamicsWorld->setGravity(btVector3(0,-9.8,0));
}Code: Select all
void bPhysicsAddPlayer(btKinematicCharacterController ** p_character,
btPairCachingGhostObject ** p_ghostObject)
{
btTransform startTransform;
startTransform.setIdentity ();
startTransform.setOrigin (btVector3(-0.9, 8.0, 0.8));
*p_ghostObject = new btPairCachingGhostObject();
(*p_ghostObject)->setWorldTransform(startTransform);
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btScalar characterHeight=1;
btScalar characterWidth=0.3;
btConvexShape* capsule = new btCylinderShape(btVector3(characterWidth, characterHeight, characterWidth));
(*p_ghostObject)->setCollisionShape (capsule);
(*p_ghostObject)->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.2);
*p_character = new btKinematicCharacterController (*p_ghostObject,capsule,stepHeight);
dynamicsWorld->addCollisionObject(*p_ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
dynamicsWorld->addAction(*p_character);
}I realise that this forum has more people asking questions than those who can answer those questions! I promise that when I get more knowledgeable about bullet, I'll contribute to the society as much as possible ... in the mean time, please help me get over the first part of the learning curve!
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: [UPDATED]kinematic character doesn't slide against walls
This is fast turning into a one-man discussion. No matter! At least this will serve as documentation for someone who has the same problem in the future.
I found this thread:
http://bulletphysics.org/Bullet/phpBB3/ ... tep#p10869
..and tried changing the member variable 'm_addedMargin.' (in btKinematicController.cpp) 0.3f seems to give me the best result; anything less and the character stays suck to the wall. Anything more and the character starts jumping and moving all over the place.
Even at 0.3, the movement is a bit jumpy (only as I slide against the wall).
I'll look into this now. Also, the falling speed issue might have something to do with 'm_fallSpeed' but I'll look into that later.
I found this thread:
http://bulletphysics.org/Bullet/phpBB3/ ... tep#p10869
..and tried changing the member variable 'm_addedMargin.' (in btKinematicController.cpp) 0.3f seems to give me the best result; anything less and the character stays suck to the wall. Anything more and the character starts jumping and moving all over the place.
Even at 0.3, the movement is a bit jumpy (only as I slide against the wall).
I'll look into this now. Also, the falling speed issue might have something to do with 'm_fallSpeed' but I'll look into that later.
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: [SOLVED] kinematic character doesn't slide against walls
I managed to get the problem to the point where it is not really an issue.
My ghost object collision shape was a cylinder, not a capsule. Setting it back to a capsule made the problem less severe ... there is still a small amount of jumpy movement, however.
My ghost object collision shape was a cylinder, not a capsule. Setting it back to a capsule made the problem less severe ... there is still a small amount of jumpy movement, however.
-
gennoevus
- Posts: 39
- Joined: Sun Oct 10, 2010 4:39 am
Re: [SOLVED] kinematic character doesn't slide against walls
The jittery-ness is solved!
It was just a stupid bug in my code. Here is the offending line of code:
changed it to:
I thought walk direction was setting the walk distance, not the walk speed, so I was *-ing it by the amount of time passed since the last frame.
Also I had to make the FLY_SPEED constant a lot smaller, obviously
It was just a stupid bug in my code. Here is the offending line of code:
Code: Select all
g_character->setWalkDirection(btVector3(sin(l_yaw*DEG_TO_RAD)*FLY_SPEED*bTimerTimePassed(), 0, -cos(l_yaw*DEG_TO_RAD)*FLY_SPEED*bTimerTimePassed()));Code: Select all
g_character->setWalkDirection(btVector3(sin(l_yaw*DEG_TO_RAD)*FLY_SPEED, 0, -cos(l_yaw*DEG_TO_RAD)*FLY_SPEED));