Following this YouTube tutorial and he explains how to make it so the game manager object ends the game when the player collides with an obstacle. When I try it I get this error code on the PlayerCollision script (it’s a component on the player) -
Assets/Scripts/Player Scripts/PlayerCollision.cs(24,21): error CS0246: The type or namespace name `GameManager’ could not be found. Are you missing an assembly reference?
this is the whole script -
using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public PlayerMovement movement;
public Transform player;
public void OnCollisionEnter (Collision collisionInfo )
{
GameObject varGameObject = GameObject.Find("Player");
if (collisionInfo.collider.tag == "Reset")
{
transform.rotation = Quaternion.Euler (0, 90, 0);
}
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false;
GetComponent<PlayerSteerVis>().enabled = false;
FindObjectOfType<GameManager>().EndGame();
}
}
}
And this is the script I’m referring to on the GameManager object -
using UnityEngine;
public class GameManagement : MonoBehaviour {
public void EndGame ()
{
{
Debug.Log ("GAME OVER");
}
}
}
On the PlayerCollision script when I begin to type EndGame it comes up on the predictive text type thing so surely it’s finding it so why is it saying it can’t find the object? I tried re-importing all assets with no success and I’ve tried to delete the UnityAssemblies folder which is apparently a fix but I can’t locate it. The game object is called GameManager and is in the scene, another script on the GameManager allows me to reset the game hitting the spacebar so it’s definitely there.
I’m still new at this but I thought this all made sense so is it a Unity bug or am I missing something?? I really appreciate any help or advice, thank you <3