I have 2 script one that manages animation for my AI and another that’s suppose to call that animation when the AI is shoot, but for some reason i keep getting the following error:
SendMessage resetAnimation has no receiver!
UnityEngine.Component:SendMessage(String)
ai_shooting:Update() (at Assets/Scripts/AI/ai_shooting.js:17)
Line 17 : transform.SendMessage(“resetAnimation”);
Animation.js
var model : Transform;
var hasAttacked = false;
var animationm;
function Start(){
model.animation["Walk"].speed = 2;
animationm="walk";
}
function resetAnimation(){
model.animation.CrossFade("Idle");
animationm="idle";
}
function walk(){
model.animation.Play("Walk");
hasAttacked = false;
animationm="walk";
}
function fire(){
if(hasAttacked==false){
model.animation.Play("Fire");
hasAttacked = true;
animationm="fire";
}
}
Part of the AI shooting:
function Update () {
var attack=GetComponent("ai_logic").canAttack;
if(attack==true){
time -=Time.deltaTime;
transform.SendMessage("fire");
if(time < 0.0){
time = fireRate;
fire();
}
}else{
transform.SendMessage("resetAnimation");
}
}