Hi! this is my code currently and I’m having an issue,
Basically I don’t want it to be " if (Input.GetMouseButtonDown(1)) "
I want it to be OnTriggerEnter and I’ve tried everything I can think of to fix it!
(this code is from a tutorial)
Please let me know how to fix it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour
{
public Animator transition;
public float transitionTime = 1f;
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(1))
{
LoadNextLevel();
}
}
public void LoadNextLevel()
{
StartCoroutine(LoadLevel(SceneManager.GetActiveScene().buildIndex + 1));
}
IEnumerator LoadLevel(int LevelIndex)
{
transition.SetTrigger("Start");
yield return new WaitForSeconds(transitionTime);
SceneManager.LoadScene(LevelIndex);
}
}
I’m not sure if your wrong, but I’ll try to go more in depth.
When i walk into a trigger i would like it to switch scenes but while that happens I want a animation to play.
I Tried. else, if, void, public void, private void, [MonoBehaviour.OnTriggerEnter(Collider), and all other variations I could think of. I started coding like a week ago so I’m probably just dumb.
about the errors, it was a ton of them and I kept fixing them and then new ones would be created.