using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Change : MonoBehaviour {
public float TriggerObject;
void OnTriggerEnter (Collider other) {
if (other = TriggerObject) {
SceneManager.LoadScene("Lv2");
}
}
}
TriggerObject is what is getting the error(2nd time its used)
1 Answer
1
So a couple things first off your if statement comparison is incorrect you are using a = (assignment operator) instead of == (equal comparator). Also why is your TriggerObject a float. It should be a Collider if you want it to be comparable/settable to the other Collider. So I would say change it to the following and see if that helps:
public Collider TriggerObject; // should be a Collider to match the 'other' variable
void OnTriggerEnter (Collider other) {
if (other == TriggerObject) { //change = to == for comparison
SceneManager.LoadScene("Lv2");
}
}
Hope this helps!