[ad_1]
Im trying to make it were an image will pop up when the Tag player walks into trigger. after that, if the player clicks “E” it will load the next scene but wont work. here is my code
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Presstoclimbvent : MonoBehaviour
{
public int scenestart;
public GameObject Object;
// Start is called before the first frame update
void Start()
{
Object.SetActive(false);
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
Object.SetActive(true);
}
if (Input.GetKeyDown(KeyCode.E))
{
SceneManager.LoadScene(scenestart, LoadSceneMode.Single);
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "Player")
{
Object.SetActive(false);
}
}
}
[ad_2]