Page 1 of 1

Simplified Character Code

Posted: Sun May 04, 2008 10:52 am
by jstroh
Could you possibly post some code for a simplified character. I essentially don't want state models, setting the camera, etc.

From the looks of it you create a box for the feet via 2 rays and then use that box for the feet collision.

Ok so say I had the box made and stored as an entity.

Suppose also this box was stored within my own character (actor) class.

What code would be needed in my (actor) update loop to collide the? I'm guessing a converted version of CharacterController's update. Would it be ok to place that code in an XNA update function instead of a physics update function?

and then just use applyMovementImpulse to move?

Thanks

Re: Simplified Character Code

Posted: Sun May 04, 2008 6:06 pm
by Norbo
I'll see what I can do about example code. Might take a while.

Overall, there are two entities involved- the detector, a physically simulated intangible entity which collects raycast candidates, and the body entity, like a capsule for collision. I'll assume that it's dynamic for this post (nondynamic relies less on the physics engine and more on tweaks). The detector fully encloses the ray (or multiple rays if you have chosen to go that route) and provides it with a very specific list of objects that may act as support.

These two entities should be added to the space; from there, the physics side is handled. Collisions and response and all that fancy stuff will work out- the movement impulses/friction and support forces are the other piece. These can be calculated within an Updateable's update, or in an 'external' update. The only real difference at this point is timing as Updateable's update is called sooner, though in the future there will be some threading fanciness involving Updateables.

Re: Simplified Character Code

Posted: Mon May 05, 2008 2:00 pm
by jstroh
Cool. I'll just go ahead and tinker with it.