- Home /
Setting Layer Weights properly
Hi, Im am making a huge oversight I just cant see it but my set layer weight is only working for my secondary for my primary the weight goes half or less sometimes clicking it multiple times increased the weight to 1
Relevant Code: bool isPrimary; bool isSecondary;
Animator _animator;
int aimLayerIndex;
void Start() { _animator.SetLayerWeight(1, Mathf.Lerp(_animator.GetLayerWeight(1), 0f, Time.deltaTime * 10f)); }
if (Input.GetButtonDown("PrimaryWeapon") || (Input.GetAxisRaw("Mouse ScrollWheel") > 0f)) { isPrimary = true; isSecondary = false; EquipItem(0); } if (Input.GetButtonDown("SecondaryWeapon") || (Input.GetAxisRaw("Mouse ScrollWheel") < 0f)) { isSecondary = true; isPrimary = false; EquipItem(1); }
if (isPrimary)
{
//animation
_animator.SetLayerWeight(1, Mathf.Lerp(_animator.GetLayerWeight(1), 1f, Time.deltaTime * 10f));
_animator.SetBool("isPrimary", true);
_animator.SetBool("isSecondary", false);
}
if (isSecondary)
{
//animation
_animator.SetLayerWeight(1, Mathf.Lerp(_animator.GetLayerWeight(1), 1f, Time.deltaTime * 10f));
_animator.SetBool("isPrimary", false);
_animator.SetBool("isSecondary", true);
}
else
{
_animator.SetBool("isPrimary", false);
_animator.SetBool("isSecondary", false);
}
I will clean up the code don't worry it mostly looks like this from many iterations of a simple mistake but any help would be much appreciated!