CharacterController questions

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
diabloqfdb
Posts: 38
Joined: Mon Aug 20, 2012 10:33 am

CharacterController questions

Post by diabloqfdb »

I started using CharacterController from the demo in order to have physics based movement in the game. The first thing I did is replace my camera with the one from the demo. This was problematic and took some time and even now is not working quite properly. Raytracing from camera position/direction is broken. Then I added a CharacterControllerInput and after calling activate, it pretty much worked as expected. I did get suck one in terrain though once.

So here are my questions:
1. I am supposed to use character.CharacterController.StanceManager.StandingHeight to determine the cylinder height and character.CharacterController.BodyRadius for the cylinder radius? The top of the cylinder should be the top of the characters head, because when jumping you want to avoid the eye level getting up to/past the roof. How do you do this? With character.StandingCameraOffset? What kind of values does that take?
2. In order to increase the jump distance, I modified character.CharacterController.JumpSpeed *= 10. What is character.CharacterController.JumpForceFactor used for?
3. How to change the movement speed? After I activate the controller, the camera speed is ignored and I can't seem to change it anymore. Deactivating the controller makes the camera move at the desired speed again.
4. How to create a controller that flies around like a camera, but with collision so the cylinder does not clip thought items? Basically behaving like a normal controller without gravity?
5. How to control the force with which the controller interacts with the surroundings. And is it possible to make it so that it does not interact with some items, like some small items on the floor that I don't want pushed around by walking?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CharacterController questions

Post by Norbo »

1. I am supposed to use character.CharacterController.StanceManager.StandingHeight to determine the cylinder height and character.CharacterController.BodyRadius for the cylinder radius?
Yup.
The top of the cylinder should be the top of the characters head, because when jumping you want to avoid the eye level getting up to/past the roof. How do you do this? With character.StandingCameraOffset? What kind of values does that take?
The CharacterControllerInput is just a simple example interface showing one way of interacting with the CharacterController, so there's no single built-in correct way to do this. But yes, in the CharacterControllerInput, the StandingCameraOffset is the offset from the character entity's position to the position of the camera. In other words. camera.Position = characterController.Body.Position + StandingCameraOffset.
2. In order to increase the jump distance, I modified character.CharacterController.JumpSpeed *= 10. What is character.CharacterController.JumpForceFactor used for?
JumpForceFactor scales the force applied to the object that is the support at the time of the jump. Unless you have a specific goal in mind, leave it at 1.
3. How to change the movement speed? After I activate the controller, the camera speed is ignored and I can't seem to change it anymore. Deactivating the controller makes the camera move at the desired speed again.
The camera is a completely separate beast. When active, the CharacterControllerInput takes control of the camera's position. The CharacterController.HorizontalMotionConstraint.Speed property controls how fast the character can run. There's other speed properties for the various states that the character can be in- sliding, crouching, and in the air.
4. How to create a controller that flies around like a camera, but with collision so the cylinder does not clip thought items? Basically behaving like a normal controller without gravity?
Instead of using a character controller, just make a sphere entity. Set the sphere's IsAffectedByGravity to false. Control the sphere entity's velocity with user input. Set the camera's position to the sphere's position.
5. How to control the force with which the controller interacts with the surroundings.
The CharacterController.HorizontalMotionConstraint.MaximumForce controls how much force the character's feet can apply (while standing). There's equivalent properties for sliding, crouching, and being in the air. Note that these properties control how fast the character accelerates/decelerates too.
And is it possible to make it so that it does not interact with some items, like some small items on the floor that I don't want pushed around by walking?
Yup. Check out the collision rules documentation and CollisionFilteringDemo in the BEPUphysicsDemos.
Post Reply