So I'm building a simple platformer in Unity and It's coming along really nicely, getting through it all and I'm nearly at the point where I can put in some proper respawn mechanics, I'm following a tutorial that if having me divide up the mechanics into classes to attach to various gameobjects which makes perfect sense, but it's made me do something that Unity is screaming at me for and I want to double check if it's not the version of Unity that I have which is the cause.
You may have been wondering why my thread has been so utterly devoid of updates and this is why, I'm also working a lot on my artwork so it doesn't suck so much anymore.
LevelManager Class
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
public GameObject currentCheckpoint;
private PlayerController player;
// Use this for initialization
void Start () {
player = FindObjectOfType
();
}
// Update is called once per frame
void Update () {
}
public void RespawnPlayer()
{
Debug.Log ("Player Respawn");
}
}
KillPlayer Class
using UnityEngine;
using System.Collections;
public class KillPlayer : MonoBehaviour {
public LevelManager levelManager;
// Use this for initialization
void Start () {
levelManager = FindObjectOfType ();
}
// Update is called once per frame
void Update () {
}
void onTriggerEnter2D (Collider2D other)
{
if (other.name = "Player")
{
levelManager = RespawnPlayer();
}
}
}
I'm using this tutorial series on youtube to get my game set up.
https://www.youtube.com/watch?v=ndYd4S7UkAUIt's very good but and he has been sure to mention a few changes in Unity 5 ( the current version I have which this series doesn't use ) but I'm wondering if he's forgotten to mention a couple of things. As you can see it's all very basic my only problem with this code has been this little line of code
public void RespawnPlayer()
With the error showing up on this line claiming the above line doesn't exist.
levelManager = RespawnPlayer();
Now the function is obvious, it's a setup so you can send a debug message once you come in from KillPlayer when you enter an enemy or obstacle sprite with a collision box. However when I go back to KillPlayer I discover that unity despite having correctly created the void in LevelManager seems to think that it doesn't exist.
It makes me wonder if things haven't changed again in the latest version, I'm still busy working it out but I figured since you guys know so much about programming I'd ask you unless I suddenly stumble across the answer in the next five minutes. The culprit in this case is usually a fucking annoying typo somewhere or I've forgotten to declare a variable and so on but all that seems to be happening is for some reason when the KillPlayer class is trying to connect to the LevelManager class it decides to freak out.
I appreciate any help you guys can give me in advance!