OnCollisionEnter - warning in 3D Test Game
This Test Game is using the OnCollisionEnter function to detect whether or not the enemy is standing on some specific serfaces. It is also used for the player to collect "objective" cubes(like how pacman eats his pellets). The following Code is used universally for both the enemy and the objective. Enemy script:
public class Collision : MonoBehaviour { public Chase chase;
void OnCollisionEnter (Collision collisionInfo)
{
if (collisionInfo.GetComponent<Collider>().tag == "Fart")
{
DizzyDisco();
}
}
void DizzyDisco()
{
chase.enabled = false;
}
}
Objective script: public class ObjectIveBehavior : MonoBehaviour { public Vector3 Offset;
public Transform[] objectiveSpawn = new Transform[4];
void ObjectiveCollected()
{
int a = (int) Random.Range(0, 9);
transform.position = objectiveSpawn[a].position + Offset;
}
void OnCollisionEnter(Collision collisioninfo)
{
if (collisioninfo.GetComponent<Collider>().tag == "Player")
{
ObjectiveCollected();
}
}
} And lastly for ending the game: public class EndingScript : MonoBehaviour {
void OnCollisionEnter (Collision collisioninfo)
{
if (collisioninfo.GetComponent<Collider>().name == "Ending")
{
SceneManager.LoadScene(3);
}
if (collisioninfo.GetComponent<Collider>().name == "Enemy")
{
SceneManager.LoadScene(2);
}
}
}
After updating Unity form 2.6 to 2.13 the following warning occurred preventing the use of these scripts. Script error: OnCollisionEnter This message parameter has to be of type : Collision.
I Truly have no idea why this is happening. If anybody has some insight into a possible cause and fix, please let me know.
P.S I am very new to Unity and c# and my limited knowledge may need some "encouragement" to understand what is going on.
Thanks Paul