I have a problem with this script

Updated on March 23, 2018 in  [R] Scripts
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
3 on March 22, 2018

this is my Code for Death/Respawn but it doesnt work, can someone help me pls I’m a Noob

[/code]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class DeathOnContact : MonoBehaviour
{

    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == “Spikes”)
        {
            SceneManager.LoadScene(“Crap Mario”);
        }
    }
}

 

  • Liked by
Reply
0 on March 22, 2018

Is this script on the player or the spikes?

Does the player have a collider and a rigidBody?

On the spike’s collider, is “Is Trigger” checked?

Do the spikes have their tag set to “Spikes”? (with a capital ‘S’)

And has the scene “Crap Mario” been added to the build? You can only load scenes that have been added to the build.

 

also, use gameObject.CompareTag(“Spikes”), it’s a bit more efficient.

  • Liked by
Reply
Cancel
1 on March 23, 2018

I checked everything there seems to be nothing wrong with my settings

on March 23, 2018

Is this script on the player or the spikes?

Does the player have a collider and a rigidBody?

On the spike’s collider, is “Is Trigger” checked?

Show more replies
  • Liked by
Reply
Cancel