Hey All,
I’m working on an ingame tutorial to give the player some info.
I’ve set it up so that everytime the player presses a certain key the array goes to the next gameobject.
However when I have to times the same keybind after each other it repeats the same keybind instead of waiting for me to press it again.
This is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TutorialManager : MonoBehaviour
{
public GameObject popUps;
private int popUpIndex;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
for (int i = 0; i < popUps.Length; i++)
{
if (i == popUpIndex)
{
popUps*.SetActive(true);*
}
else
{
popUps*.SetActive(false);*
}
if (popUpIndex == 0) //first sentence
{
if (Input.GetMouseButtonDown(0))
{
popUpIndex++;
}
}
else if (popUpIndex == 1) //2nd sentence
{
}
else if (popUpIndex == 2) //3rd sentence
{
if (Input.GetButtonDown(“Inventory”))
{
popUpIndex++;
}
}
else if (popUpIndex == 3) //4th sentence
{
if (Input.GetButtonDown(“Inventory”))
{
popUpIndex++;
}
}
else if (popUpIndex == 4) //5th sentence
{
if (Input.GetMouseButtonDown(0))
{
popUpIndex++;
}
}
}
}
void OnTriggerEnter(Collider other)
{
if (other.CompareTag(“Player”)) if (popUpIndex == 1)
{
popUpIndex++;
}
}
Anyone know how I can fix this? Thanks in advance!