- Home /
SendMessage walk has no recieveer
hello, I am having a problem with some SendMessages, i have one for walk, one for reset and for gotHit, those are my only Sendmessages and they all say the same: SendMessage ... has no reciever. hat i am trying to do here is to make the AI stop with his walking animation if he stops.
code for walk and reset:
var model : Transform;
function Start(){
walk();
}
function reset(){
model.animation.CrossFade("idle");
}
function walk(){
model.animation.Play("walk");
}
and here i send the message
if(velocity>0)
transform.SendMessage("walk");
else
transform.SendMessage("reset");
and for gotHit it is pretty much the same
please help me.
Answer by Berenger · Mar 09, 2012 at 11:23 PM
That should work. Are you sure the Transform your sending the message to (btw, it is the Transform of the script with "if( velocity ...)") has the script with walk and co functions ?
Answer by rutter · Mar 09, 2012 at 11:26 PM
If you call SendMessage("Walk")
on a GameObject named "Sally" and get a message saying there was no receiver, that implies there is no script attached to Sally which has an appropriate function to call.
Is the script sending the message attached to the same GameObject as the one you're hoping will receive it?
Sort of, it is attached to one of its childs (the function walk and reset is a child of the Send$$anonymous$$essage)
Answer by hijsm · Mar 10, 2012 at 09:47 AM
Oh, i already got it, I pasted the script on the wrong GameObject, thanks rutter. though I still get the error of gotHit, but I will take a look at that because i did not jet do that