When i increase the radius of a Capsule Collider when the game is running my object moves up in the y.
if(Input.GetKey(KeyCode.LeftArrow))
{
speed -= 1f*Time.deltaTime;
}
else if(Input.GetKey(KeyCode.RightArrow))
{
speed += 1f*Time.deltaTime;
}
speed = Mathf.Clamp(speed,-1,1);
CapsuleCollider cc = GetComponent<CapsuleCollider>();
cc.radius = Mathf.Lerp(0.2f,0.5f,Mathf.Abs(speed));
As the radius increases the object moves up in the y.
To fix this i have to subtracted from the Capsule Collider height
The height of my object is 2 and the radius moves from 0.2 to 0.5 depending on speed
cc.height = 2.0f - ((cc.radius-0.2f)*0.1f);
This makes the object stay on the ground.
Is this a known bug or am i missing somthing?
Cheers
Pete