Writing a new KCC based on bullet?

Hey guys!, i’m now looking to write my own kinematic character controller. Problem is I don’t know how :wink: Could you point me in the right direction?
I have read some code from coppertop and i found this article
To put in into perspective: I mostly do web design & php/js apps. I have never touched graphical programming until two weeks ago :slight_smile: What would you guys recommend for learning character control? What questions should i even ask?

Writing a good kinematic character controller for one specific game is not a task for beginers. Big game companies are challenged with this task, and frequently they deliver bad results. Even more difficult is to write a generic KCC which is suitable for any game.

I suggest you check out this thread [New Bullet Character Controller), and try to figure out what you are missing (features/issues/…). Then try to understand what coppertop has done, and ask questions about how it could be added to his code.

Coppertop is the one guy around here who has the most experience with KCC. So this is really the best place to start.

Thanks enn0x, I have read coppertop’s bullet kcc before and believe porting the rest of his ode code to bullet is my first task.
Correct me if im wrong but casting a ray when player “shoots” is faster/less expensive in bullet than in ode? or should I like coppertop always have a ray cast?

My game i’m working on is a FPS and coppertop’s kcc is just what i need.

But what I really need is more or less a “theoretical kcc for dummies” guide.

Raycasting, when and when not to.
Object interaction, something that’s not covered in coppertop’s ode?
Should rockets be implemented like his ode grenades?
How should surface types be implemented? (less friction on ice and more on rubber)

I doubt there’s any code left to port that’s specifically related to KCC (maybe except moving platforms). Carrying and shooting is not, by any means, a task that should be included in a KCC code. Despite how widespread it is in games, it’s too gameplay specific. As an easy to integrate addon – sure. Integrated – absolutely not.

As far as shooting – in ODE having the ray stuck to your face all the time is MUCH faster. In Bullet, it’s better and easier to do it the right way, which is to cast the ray only when you need it. Obviously, you should still be smart about it. For instance, if your rifle shoots faster than your game renders, just do one ray cast and use it for all rounds fired within a frame. Otherwise, you’ll just slow down your game, but won’t achieve any additional aiming precision, because it’s lost in framerate anyway.

I don’t understand what you mean about “raycasting, when and when not to”. Raycasting is cool, because it’s fast and simple to use. If it doesn’t fit your needs, casting a sphere probably will, although I’m not sure if Panda’s Bullet supports getting more than the closest colliding geom for geom tests – if not, you will mostly find nothing but your capsule, which is of very little usefulness.

Object interaction is something that will, most probably, be very game specific. Same with weapons. If you want to make a rocket launcher, the rockets may be dynamic or kinematic. They might be affected by gravity or not. They may or may not be guided and if so, there are many ways to approach that – laser (as in, fly where I point, like in Half Life), heat, marker? There are so many different possibilities… Not to mention that the rocket’s spawn point is also as much a matter of engineering as it is a matter of game design. In some games, you’ll want your rockets to really be fired from the launcher (resting on the character’s shoulders). In other games, you might prefer to cheat and spawn the rocket at the center of the screen, to meet player’s expectation regarding aiming, which will pose a necessity to hide that fact with a nice animation (the rocket can’t just appear in front of your eyes out of thin air). And so on, and so on…

About surface types, IIRC you can get that information and just tweak the KCC speed and such. If you want the KCC to slide on ice (which would be a nice feature, BTW), you would probably use a task triggered by an -up button message for that. And you would slow the KCC gradually over time.

An important thing to note.

The Bullet KCC I wrote is not less feature complete than the ODE KCC. Ignoring the lack of moving platforms (which is also a rather game specific thing and functional requirements may vary largely), it actually has MORE features.

The thing with the ODE implementation is that it comes with a large demo full of things that aren’t really KCC stuff. That’s why I renamed it to ODE Middleware at some point. It had a lot of stuff that Bullet comes with OOTB (like CCD) and a lot of stuff that, once far enough in development, most people would rewrite anyway, to better fit their games (like weapons or carrying mechanics).

Just wanted to make it clear where “a KCC” ends and where “rest of a game” begins :slight_smile:.

Hmm maybe I have somewhat confused the terms in here, What I want is a player character controller based on your KCC.
I’m already extending my pcc with your kcc, and working to build something similar to your ode guns.py in bullet.

But in the end it’s still a kinematic character controller with more “features” for lack of better word, so I do believe I understand the separation. :slight_smile:

Regarding object interaction, it’s just what your ode middleware has such as doors, ladders and chairs i want in bullet for now, much later i would add things like teleporters, vehicles, big red buttons, rockets and so on 8) . But you don’t have all those things in your code so i was looking for, oh lets say a dev-diary of something similar or something like that to get me started (maybe not vehicles since the manual covers that).

I think you answered all questions I have now, thanks!

I admit i’m mostly afraid of reinventing the wheel unnecessarily (I was heading towards doing just what you described NOT to do with a rifle & raycasting) :blush: so just about any tips, guides or examples would be really welcomed right now :smiley: