Page 1 of 1

Character height bug

Posted: Sun Apr 29, 2012 1:04 pm
by ole_92
Hi again,

I'm experiencing a very strange bug with the character height. As soon as the game starts, the character is at certain height, say 100%.
But as soon as he does his first crouch, his standing height is now about 60% of the original.

This is the code that I use to create the character:

Code: Select all

cci = new CharacterControllerInput(space, ((Game1)Game).camera);

            cci.CharacterController.Body.Radius *= 0.8f;
            cci.CharacterController.HorizontalMotionConstraint.Speed = 70;
            cci.CharacterController.HorizontalMotionConstraint.CrouchingSpeed = 20;
            cci.CharacterController.StanceManager.CrouchingHeight = 20f;
            cci.CharacterController.StanceManager.StandingHeight = 41;
            cci.StandingCameraOffset = 14;
            cci.CrouchingCameraOffset = 10;
            cci.UseCameraSmoothing = true;
            cci.CharacterController.HorizontalMotionConstraint.MaximumForce = 4000;
            cci.CharacterController.StepManager.MaximumStepHeight = 20;

            cci.Activate(); 

Do you have any clue why it's happening?

Thanks

Re: Character height bug

Posted: Sun Apr 29, 2012 2:45 pm
by Norbo
Is the character just saying in the crouched state? Top stop crouching, the stance must be explicitly changed to standing again.

Is the character body itself not returning to the correct shape, or is it just the camera in the wrong spot?

Additionally, while this doesn't necessarily explain the height issue, there are some properties there being set after construction which are not designed to be set after construction. The character wasn't designed for taking into account post-construction changes. That's why the CrouchingHeight and StandingHeight setters are private by default. The body's radius should also not be set after construction. Instead of configuring these after the fact, modify the first initialization (for example, in the constructors), or ensure that any post-modification gets understood by the character properly. (I might make this easier in the future.)

Re: Character height bug

Posted: Mon Apr 30, 2012 12:58 am
by ole_92
Apparently, a long time ago, I have commented out the two lines in StanceManager, and that caused the issues... all working now, thanks!