Hi, noob here, back for more help! Hopefully one of you competent types can help me out here, I’m trying to set up a collider which will activate the next level on ‘Use’. My scene index is arranged properly and “Use” is setup.
Can anybody see what I’m doing wrong? it’s the void Sleepy part that doesn’t work
Many thanks in advance,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class BedSleep : MonoBehaviour
{
public GameObject UseBedSign;
bool Sleep = false;
void Start()
{
UseBedSign.SetActive(false);
}
public void OnCollisionEnter2D(Collision2D player)
{
if(player.gameObject.tag == "Player")
{
UseBedSign.SetActive(true);
Sleep = true;
}
}
public void OnCollisionExit2D(Collision2D player)
{
if (player.gameObject.tag == "Player")
{
UseBedSign.SetActive(false);
Sleep = false;
}
}
public void Sleepy()
{
if (Sleep == true && Input.GetButtonDown("Use"))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}