so i want my player sprite getting to next level by avoiding 5 colliders. so how i code it?
im new here, pls help me :frowning:

heres my code

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

public class player : MonoBehaviour
{
public float moveSpeed = 600f;

float movement = 0f;

// Update is called once per frame
void Update()
{
   movement = Input.GetAxisRaw("Horizontal");
    
}

private void FixedUpdate()
{
    transform.RotateAround(Vector3.zero, Vector3.forward, movement * Time.fixedDeltaTime * -moveSpeed); // untuk membuat hexagon mengerucut seiring berjalannya waktu
}

private void OnTriggerEnter2D(Collider2D collision)
{
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

},so i have this player sprite, i want to make this player survive the collider 5 time so it can continue to next level(new scene)
heres the code

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

public class player : MonoBehaviour
{
public float moveSpeed = 600f;

float movement = 0f;

// Update is called once per frame
void Update()
{
   movement = Input.GetAxisRaw("Horizontal");
    
}

private void FixedUpdate()
{
    transform.RotateAround(Vector3.zero, Vector3.forward, movement * Time.fixedDeltaTime * -moveSpeed); // untuk membuat hexagon mengerucut seiring berjalannya waktu
}

private void OnTriggerEnter2D(Collider2D collision)
{
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

}

What do you mean by “avoiding 5 colliders”? Do they move towards the player? Let’s assume you can check if the player avoided the collider with function “bool avoided()”. What you do is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class player : MonoBehaviour
{
   int collidersAvoided = 0;
   
   void Update()
   {
       if(avoided())
         collidersAvoided++;
   }

   private void OnTriggerEnter2D(Collider2D collision)
  {
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

    // If you just want to reset the score to zero, use:
    // collidersAvoided = 0;
    // It's faster than loading an entire scene
  }

}

But then, I don’t know what do you mean by “avoiding colliders”, so I don’t know how to check it.

have a script up for your colliders and have OnTriggerEnter function in it that checks if the ball is colliding with the colliders or not. Put a collider on your hole and give a OnTriggerEnter function that checks if the ball goes in, load the next level.