Collision Not regestering
Hey, I've been working on a parkour/platformer game and I want it so when you fall you will teleport to another scene that says you died and a try again button, but its not working , it'll just make him fall here's the code using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class deathScript : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D other) {
if (other.gameObject.tag == "DEATH")
{
SceneManager.LoadScene("Loose scene");
} else if (other.gameObject.tag == "")
{
}
}
}
And here's the pictures of my config
Comparing tags directly is not ideal, try using
other.gameObject.CompareTag("DEATH")
instead.
Also, where is your script attached to? Did you actually attach it to the player? If you didn't that will never work.
Next question: did you add the scenes you want to load to the build settings? If they're not setup correctly Unitt won't be able to find them when you request the load.
The issue could be pretty much anything, if you have errors in the console please share those as well.
Answer by blakewmcleod · Mar 12 at 03:28 AM
@XAlwalidX Death script is not on the player unless character controller calls it
Your answer
Follow this Question
Related Questions
Having trouble with 2D Jumping 0 Answers
How to Handle Slopes in 2D Platformers? 1 Answer
2D Platformer Projectile wont face mouse position? 0 Answers
Walking around 2D planets? 1 Answer
Player controlled platforms 0 Answers