I have a script (the first one below) that if I press X the player animates and the sword as well if its equipped. The player animates correctly when i press X but the sword animation dont show at all.
The problem as i understand it that cant find it since its on -1 and cant play the animation but i never had a -1 layer and never had anything there as far as i understand. Below is the problem Unity points to with the Invalid Layer -1 problem. I have to clue on what to do to to fix it some please help me. And talk to me like im a noob-ish
public void PlayAnimation(AnimationClip clip)
{
//anim.SetInteger("State", 1);
anim.Play(clip.name);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Weapon weaponEquipped;
private Attack attack;
private Animator anim;
public float fireRate;
private float nextAttack;
void Start()
{
anim = GetComponent<Animator>();
attack = GetComponentInChildren<Attack>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.X) && Time.time > nextAttack && weaponEquipped !=null)
{
anim.SetTrigger("Blade_Attack");
attack.PlayAnimation(weaponEquipped.animation);
nextAttack = Time.time + fireRate;
}
}
public void AddWeapon(Weapon weapon)
{
weaponEquipped = weapon;
GetComponentInChildren<Attack>().SetWeapon(weaponEquipped.damage);
}
}