So I’ve been trying to make this feature in my game where you could walk up the stairs and then it would change scene (change floor). But I’m not really understanding where I should put the scprit or how I should code this. Here is my current code(this script is all the 3 diffrent Grid sections):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StairController : MonoBehaviour
{
bool Up = false;
bool Down = false;
void Start()
{
Debug.Log("Hello");
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag=="StairUp")
{
Up = true;
Down = false;
}
if(other.tag=="StairUp")
{
Down = true;
Up = false;
}
if(other.tag=="StairConfirm" && Up==true)
{
Debug.Log("Up");
}
if(other.tag=="StairConfirm" && Down==true)
{
Debug.Log("Down");
}
}
}
So how this works is that I have 3 different tilemaps and 3 different tags. One for Up, Down and Confirm. The stairs are built in a 3 area kinda way. First you either enter a UpStair or a DownStair, and then you come to the confirm area.
The green parts are the diffrent areas, the exclamation mark for walls, and purple is just the floor. So green area above the middle is UpStair, and under that is DownStair. And lastly the green area to the right is Confirm.
But the problem is that nothing happens in the console.
It’s kind of a mess, maybe you guys have sometips on how to make this less messy?