Trying to get a method from another class to be executed in this class, but it keeps giving me this error
“Assets/Scripts/KillPlayer.cs(23,36): error CS1061: Type LevelManager' does not contain a definition for RespawnPlayer’ and no extension method RespawnPlayer' of type LevelManager’ could be found (are you missing a using directive or an assembly”
I’m still new to C#, I am trying to get a spike from my platformer to trigger a Debug.Log command that is in my code that says “Respawn here”. I just don’t know what to do.
Here is my Code:
using UnityEngine;
using System.Collections;
public class KillPlayer : MonoBehaviour {
public LevelManager lvlManager;
// Use this for initialization
void Start () {
lvlManager = FindObjectOfType<LevelManager>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEffect(Collider2D other){
if (other.name == "Player") {
lvlManager.RespawnPlayer();
}
}
}
And here is the class that I am trying to extend its method onto the class you see up above.
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void RespawnPlayer(){
Debug.Log ("Respawn Here");
}
}
Any help would be greatly appreciated.