I have a little bug in my game and I want to be sure that no one can use this.
I let the CharacterController shrink and get bigger with a Mathf.Lerp function.
that works fine but I want that he stands up slow and get faster till the endsize…
I thought I could use a animation curve to solve this problem but I dont know how to use one and I dont find something useful un the internet.
here is the code I use for the crouch uncrouch so that the character dont fall through the ground.(the code is not complete I just copied the important parts)
function Awake()
{
chMotor = GetComponent (PlayerMotor);
ch = GetComponent (CharacterController);
tr = transform;
height = ch.height;
}
function FixedUpdate()
{
var h = height;
if (isCrouching == true)
{
h = 0.5 * height;
}
var lastHeight = ch.height;
ch.height = Mathf.Lerp(ch.height, h, 6*Time.deltaTime);
tr.position.y += (ch.height - lastHeight)/2;
}