In the spot //wait 1.5 seconds
what would I say to make it wait 1.5 seconds then complete the code after?
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnclickHeal : MonoBehaviour
{
public PlayerHealth playerHealth;
public PlayerMovement playerMovement;
public Inventory Inventory;
public Button healButton;
void Start()
{
Button btn = healButton.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
void TaskOnClick()
{
playerMovement.moveSpeed = 3;
//wait 1.5 seconds
playerMovement.moveSpeed = 4;
playerHealth.currentHealth = 100;
}
}
Also, the line public Button healButton;
throws an error:
error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)
Button
type. It's in theUnityEngine.UI
namespace, so where you have thoseusing
lines at the top of the file, you should addusing UnityEngine.UI;
. Your IDE should also suggest this fix if you hover over the line giving the error. \$\endgroup\$