Trouble making a restart button.
Hi guys,
I made the topdown shooter game using the Unity tutorial. Everything went great so far, until I wanted to make a screen at the end with a "replay" button, which replays the (active) scene. I've been trying and googling for hours now but I can't get it figured out, and I was hoping one of you guys could help me out :)
When I try to run my code I get the following error
'Player' AnimationEvent 'RestartLevel' has no receiver! Are you missing a component?`
Here is the script that I linked to the button.
using UnityEngine;
using UnityEngine.SceneManagement;
public class MenuScript : MonoBehaviour
{
public void RestartLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612144910im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Expose method with Enum parameter to editor 0 Answers
Button being phantomly pressed 0 Answers
Click option is not working in GameView with some different clicker 0 Answers
How to change HotKeys for UI Navigation? 0 Answers
With the new unity input system. How do I setup UI buttons like in the old system. 0 Answers