Simplified Character Code

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Simplified Character Code

Post 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
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Simplified Character Code

Post 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.
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Simplified Character Code

Post by jstroh »

Cool. I'll just go ahead and tinker with it.
Post Reply