- Home /
The question is answered, right answer was accepted
Update and Awake not being called.
I have this script which is completely fine and stuff, but does not call Update and Awake voids, it only calls voids when they are called manually from other scripts (for example "MoveToPlayer" which is called from the enemy area script)
//removed all stuff not related to the answer since I am really careful when sharing my scripts since I dont want bad people to steal it
using UnityEngine;
using System.Collections;
public class basicEnemy : MonoBehaviour {
private Animator anim;
void Awake()
{
Rest();
anim = gameObject.GetComponentInChildren<Animator>();
}
public void Rest ()
{
anim.SetBool ("walking", false);
}
}
You sure you've got an instance of enemy class in the scene? What about "OnEnable" and "OnDisable", do they work? Post the original class, we can't help you without seeing the code
On Enable and On Disable don't work, also I'll post the original script in just a second. EDIT: ok I have now posted the original script
Answer by wojtask12 · Jul 16, 2016 at 07:25 PM
You should be getting a null reference error, due to calling anim
variable in the Rest()
function before assigning it with GetComponent
. Perhaps you turned off error logging in the console by accident
Thank you so much! I thought it just was not calling the functions when I just happened to make a stupid mistake like that :) Thank you for your help, you saved my life today :3
I just converted the comment to answer, i guess you can mark it now