I have ‘crouch’ implemented in a script, but it’s a little too quick. Is there a way to have it happen over a span of time. I’m really just beginning with all this, so the specific code I would need alludes me.
Thanks for any help you can give.
public float crouchScaleAmount = 0.01f;
private bool isCrouching;
private float intialYSize;
private float crouchYSize;
void Awake()
{
isCrouching = false;
intialYSize = transform.collider.bounds.extents.y;
}
void Update()
{
if (Input.GetButtonDown("crouch"))
{
if (isCrouching == false)
{
transform.localScale += new Vector3(0, -crouchScaleAmount, 0);
crouchYSize = transform.collider.bounds.extents.y;
isCrouching = true;
}
}
if (Input.GetButtonUp("crouch"))
{
if (isCrouching == true)
{
transform.localScale += new Vector3(0, crouchScaleAmount, 0);
transform.position += new Vector3(0, 0 + (intialYSize - crouchYSize), 0);
isCrouching = false;
}
}
}