I have a bool called “WeaponTrail” on my animator which is on the current game object. I am using the XWeaponTrail asset, and am trying to turn the weapon trail off and on for each melee swing (each attack animation state). The sword has the weapon trail attached to it. The sword is attached to the model, which is all on the same game object like normal. I am recieving a null reference exception with the following code. I’m pretty new in coding, any help would be appreciated.
using UnityEngine;
using System.Collections;
using Xft;
public class SwordTrailSwitch : MonoBehaviour {
XWeaponTrail xwep;
Animator anime;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Swordbool ();
}
//CGP turn on and off weapon trail CGP
void Swordbool()
{
if (anime.GetBool ("WeaponTrail") == true) {
xwep.Activate ();
}
if(anime.GetBool("WeaponTrail") == false) {
xwep.Deactivate ();
}
}
}