Looking for someone to help me for my 3d style game and making sure the Player doesn’t go through the Finish Line, and have the game stop completely.
Here’s my script down below.
Ah, now I get it. This wont work because you first get the Collider of the gameObject the script is attached to and then check the gameObject that has the Collider, if it has the tag “player”. But you are checking the wrong gameObject, because this Script is attached your finish line.
Attach this script to your FinishLine, make sure that the “isTrigger” on the collider is turned on and make sure you have another scene in your project and selected it after this scene so it gets loaded with buildIndex + 1.
void OnCollisionEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1)
}
}
Make sure that one of the gameObjects colliding (probably your player) has a RigidBody!
More infos here:
Also please paste your code in here instead of uploading a picture of it, thanks!