Animation Event has no receiver problem

Heres the event that triggers the function ‘hit’

here’s the script that containos the hit function

heres the object that contains the script:

here’s the error that prompted

probably needs to be public method

thanks for the reply. I tried it but still didn’t work :cry:

works here, on mine i haven’t assigned anything for the object field,
although seems to work even if assign anything there…
(tried your script, works without public also)

3346980--261612--upload_2018-1-9_12-44-35.png

which unity version you are using?
are you instantiating that prefab, does it have that script attached?

1 Like

Thanks for the replies man. I got it, the problem was that the animation itself was a read-only file and I was trying to prompt a function inside a read only file. So all I needed to do was duplicate the animation and it sort of fixed itself. Tho I did learn something from your reply thanks :slight_smile:

1 Like

It worked … Thanks

Thx a lot, this one helped me, I am not a programmer, I’ve been using Unity less than a week and I got stock 2 days with this,
I went to my assets>Animation and duplicated my only 1 animation, deleted the original and change the new ones’s name to the original’s. Then I dragged the Animation to the Animator and erased the old ones, it automaticly got linked.
It is working… much better, Before doing that, when I hit play the game would crash with the error:
‘Canvas’ AnimationEvent ‘LoadNextLevel’ has no receiver! Are you missing a component?
Now, it plays, it does not crash but short after it loads the animation and the 2nd level, it shows these new errors:

The referenced script (Unknown) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object ‘LevelComplete’) is missing!
My LevelComplete script is there:

using UnityEngine;
using UnityEngine.SceneManagement;

public class LevelComplete : MonoBehaviour
{
public void LoadNextLevel ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
the animation is linked to LevelComplete.

If I add a 3rd Level, it repeats all 3 error messages after loading the 2nd level during game play.