Im new to c# and not great at coding in general. Trying to learn. I want this game to detect when my object hits something to see if it hits something that isnt the ground or the finish and then reload the scene if it does. First i tried :
public class wallCollision : MonoBehaviour
{
public Rigidbody rb;
public Vector3 spawn;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name != "Ground")
{
Scene scene = SceneManager.GetActiveScene();
SceneManager.LoadScene(scene.name);
}
}
}
And it worked so then i changed it to this to check for the finish as well.
public class wallCollision : MonoBehaviour
{
public Rigidbody rb;
public Vector3 spawn;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name != "Ground" || "Finish")
{
Scene scene = SceneManager.GetActiveScene();
SceneManager.LoadScene(scene.name);
}
}
}
It didn't work which is why i need help. I want it to think out like:
If object collides with anything and that isn't ground or finish then.
I know I'm probably doing some simple mistake but i don't know what to search for to find help so if any one can help it would be appreciated. Thanks in advance.