THIS IS THE CLASS:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
public void NextLevel(int currentlevel)
{
if (currentlevel==1)
{
SceneManager.LoadScene("Scene 2");
}
}
}
THIS IS THE SCRIPT THAT CALL THE CLASS WITH THE METHOD:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Logro : MonoBehaviour
{
public GameManager gamemanager;
public int currentlevel;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
gamemanager.SendMessage("NextLevel",currentlevel);
}
}
}
BUT WHEN THE “PLAYER” ENTER IN THE COLLIDER IT SHOWS A ERROR, WHY??
I THINK THAT IS NOT THE WAY TO CALL A METHOD, HOW CAN I CALL IT?