by win platform i mean when i get on it i win like in the game happy wheels there’s a win platform, I’ve tried this
RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, transform.up, Win);
if (hitInfo.collider != null)
{
SceneManager.LoadScene(“sceneWin”);
}
which works but it makes me win even when im not on the platform and I’ve tried putting it on the player and on the platform but it still does the same thing
And place the collider where you want.
thank you that solved it well doing this
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag.Equals(“WinPlatform”))
{
SceneManager.LoadScene(“sceneWin”);
}
}
but the link helped so thank you
Keep your player script cleaner and put your OnCollisionEnter2D into the platform script.
Imagine if you make much more platforms with collision (events/triggers), the script on your player will be bigger and bigger.
In a small game, it’s ok.
@markjvp please read
** Using code tags properly **
It will help with readability of the code.