Question by
jihen007 · Jun 04, 2017 at 11:42 PM ·
animationanimatoranimator controller
nullException for animator states
Hello! I have a problem when trying to change a state within my character. I wrote the code below
public class playerController : MonoBehaviour {
private CharacterController characterC;
private Animator anim;
// Use this for initialization
void Start () {
characterC = GetComponent<CharacterController> ();
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
}
// put a line attack!
public void Attack(){
anim.SetBool ("attack", true);
anim.Play ("attack");
}
// when we got a box
public void Doubleattack(){
anim.SetBool ("hitBox", true);
anim.Play ("doublechop");
}
// dying animation gameover loser
public void Die(){
anim.SetBool ("isDead", true);
anim.Play ("die");
}
}
` and i use one of my methods in my "mainmanager"
public void start2PlayersGame()
{
isOnlineGame = false;
StartLevel();
PlayerManeger.set1VS1players();
AnimationManeger.showGridWindow();
plyC.Attack ();
SoundManeger.PlayBackgroudOnPlay();
}
I got this :NullReferenceException: Object reference not set to an instance of an object at ''plyC.Attack ()'' why?
Comment
Your answer
Follow this Question
Related Questions
Animator vs Animation Clip via Scripting 0 Answers
How to Apply Animation to Player 0 Answers
Opening Cutscene 0 Answers
Animator doesn't change animation in Update() function 0 Answers
2D Animation Problem. 0 Answers