Why can't I make my character die?

Trying to respawn my character when he hits the lava. Not sure why it’s not working. There aren’t any errors. It’s just not doing anything.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Death : MonoBehaviour
{

public Vector3 RespawnPoint;

public Transform player;

// Start is called before the first frame update
void Start()
{
RespawnPoint = new Vector3(0, 0, 0);
}

// Update is called once per frame
void Update()
{

}

private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == “Lava”)
{
Debug.Log(“Collision”);
Reset();
}
}

public void Reset()
{
player.position = RespawnPoint;
}
}

Did you assign your ground the Lava tag? Did the collision actually trigger?
Do the involved objects have colliders and rigidbodies?

Also please use code tags to post code :slight_smile:

Edit: Also, what is this script attached to? I see you are using a Transform player, so i assume the Death object itself is not attached to the player? But if so, the Death object colliding with Lava does not make a whole lot of sense. If Death is attached to the player you can just use its own transform, since that would be the players’.

Here’s a few tips for better in-editor debugging:

  • use Debug.Log() in strategic places in your code to identify what is running
  • use Debug.Break() pause the editor at particularly poignant moments, such as after you die
  • when the editor is paused (not stopped), go study your scene and figure out what objects are still operational, what is missing, etc.

I belive collision.collider.tag will give you other gameobjects tag.