Physics driven characters

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Physics driven characters

Post by kylawl »

I think I have a fairly good handle on what is happing with the character controller in the sample. My question is... Why is there ray cast checks on the bottom of the character? Would it not be easier to simple have a cylinder or capsule and allow it to slide around on its own? Also is the "foot" shape simply used as an optimization for determining which parts of space to check against?

Cheers

Kyle
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Physics driven characters

Post by Norbo »

It would be easier just to shove a ball around, and it can work in some situations. Raycasts allow the object to float above the ground, smoothing out bumps and letting the character climb up steps. The DynamicCharacterController is not perfect, though; it still jiggles a bit and bumps down slopes badly. This could be fixed by adding some extra fanciness, but I have been working on a kinematic character controller (would have made it into v0.5.2 but it was taking a bit too long) based on swept collision detection.

As for the feet shape, you're right, it is just for detecting candidates.
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Re: Physics driven characters

Post by kylawl »

Awesome, thanks for the like 2 second response time.
Hey, whats the future of this project? Seeing as how it's closed source, there must be an eventual commercial angle here but will there always be a non commercial version of the project?

thanks again

Kyle
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Physics driven characters

Post by Norbo »

There will definitely always be a completely free noncommercial license. As for the commercial side, the default license is free until after a significant number of sales have been made, after which point there is only a declining per-copy charge. My goal is to keep the risk for independents/hobbyists to a minimum, so that free evaluation/noncommercial license is vital. Of course, I'm not sure how many people will jump into a commercial license at this early stage, though we are using this engine for a commercial game project.

Also, if for some reason I am unable to continue maintaining the engine, my contingency plan is to release the source under a zlib-style (or similar) license.
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Re: Physics driven characters

Post by kylawl »

Cool Thanks.

Kyle
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Re: Physics driven characters

Post by kylawl »

After further running through implementing a character collision class of my own, I've noticed that updateables update before anyone else in space. In your character controller class you use that update call to collect collision data bout the feet. If the update occurrs before the controllers are updated with the new colliders, could that introduce any problems in terms of the data being a frame behind?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Physics driven characters

Post by Norbo »

The information needed by the character controller is a set of collision pairs, which is updated by the broadphase. The same collision pair set is then used by the collision detection/response systems during that frame, so in that regard, it is up to date. The updateable's snapshot will not perfectly match the end of the frame's view of course, but in most cases this should not cause serious problems.

The reason it has been placed first is that the primary purpose thus far of the updateables is to apply force, so their updates are triggered alongside the initial velocity update prior to the detection (which takes into account velocities for continuous collision detection) and the solver. It may be more intuitive to re-arrange things a bit, and it may be done in v0.6.0. Things will be forced to change fairly significantly in v1.0.0 to accommodate multithreading.

Regardless, as it stands in pre-v1.0.0 versions, there is nothing particularly special about updateables other than their position in the update sequence. Essentially the same functionality can be obtained with a completely exterior method. It may even be better to keep things outside of the updateables system if they depend heavily on the current frame's velocity/position information.
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Re: Physics driven characters

Post by kylawl »

Thanks :)

Kyle
kylawl
Posts: 11
Joined: Thu May 22, 2008 6:11 pm

Re: Physics driven characters

Post by kylawl »

For obvious reasons the physics system uses quaternions, but since they tend to be difficult to visualize... How would you work with driving character rotation? Would it be directly within quaternion space, and if so how would you get your character pointing in a given direction or for that matter determine what the quaternion is that represents a direction? Obviously in an fps, you can avoid some of these problems but in a third person game where it is important to know the direction the player wants the character to face... I'm lost.

Any insight would be appreciated.

Cheers
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Physics driven characters

Post by Norbo »

I recommend letting the character itself be some shape where rotation isn't important, like a capsule, and as such can be stopped by setting the inverse inertia tensor to the zero matrix. This obviously only works if it makes sense for your game to have a character which stays upright and such.

For the demos' character, I split the rotation of the character away from the character body itself. Instead, the camera stored the rotation, offering a fairly easy interface for modifying facing angles.

For working directly with quaternions, the XNA framework should offer all of the basic necessities, but you can stay within the bounds of sometimes-easier matrices (or even angles and trigonometry) during calculations before converting it to a quaternion and setting an orientation.
Post Reply