Hi all,
Hope you are doing well!
Out of curiosity -- is it possible to have the user press a hotkey (in this case "h") -- to toggle the hotspot reveal as opposed to just flashing it for a certain number of seconds (as I currently have)?
Just in case, I am pasting my script below. Any help is appreciated, thank you!
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;
using TMPro;
using UnityEngine.TextCore.Text;
using UnityEngine.UI;
public class HotspotHighlight : MonoBehaviour
{
public Hotspot hotspot;
private Material mat;
private Color tempColor = new Color(1f, 1f, 1f, 1f);
private Color transparentColor = new Color(0f, 0f, 0f, 0f);
public TextMeshProUGUI textObj;
public Image textBackImage;
// texture properties to make sure outline
// amount looks consistent for hotspots
public float outlineWidth = 0.024f;
public float distortAmount = 0.3f;
private const float waitTime = 2f;
// action lists controlling
// the disappearing and appearing of player when hotspots flash
ActionList playerHide;
ActionList playerShow;
private GameObject playerToHide;
private void Awake()
{
mat = GetComponent<Renderer>().material;
mat.SetColor("_Color", transparentColor);
mat.SetFloat("_OutlineWidth", outlineWidth);
mat.SetFloat("_OutlineDistortAmount", distortAmount);
playerToHide = GameObject.Find("Everlyn");
// instantiate action lists controlling system visibility
// during hotspot flash
playerHide = gameObject.AddComponent<ActionList>();
playerShow = gameObject.AddComponent<ActionList>();
textBackImage.color = transparentColor;
}
private void OnEnable() { EventManager.OnHotspotsFlash += OnHotspotsFlash; }
private void OnDisable() { EventManager.OnHotspotsFlash -= OnHotspotsFlash; }
private void OnHotspotsFlash()
{
playerToHide = GameObject.Find("Everlyn");
playerHide.actions = new List<Action> {
ActionVisible.CreateNew(playerToHide, VisState.Invisible, true),
ActionMenuState.CreateNew_TurnOffMenu("HotspotDescription", true, false, true),
ActionMenuState.CreateNew_TurnOffMenu("Hotspot", true, false, true),
ActionCharMove.CreateNew_StopMoving(AC.KickStarter.player, true),
ActionPlayerLock.CreateNew(LockType.Disabled),
ActionSystemLock.CreateNew(LockType.Disabled, LockType.Disabled)
};
playerShow.actions = new List<Action> {
ActionVisible.CreateNew(playerToHide, VisState.Visible, true),
ActionMenuState.CreateNew_TurnOnMenu("HotspotDescription"),
ActionMenuState.CreateNew_TurnOnMenu("Hotspot"),
ActionPlayerLock.CreateNew(LockType.Enabled),
ActionSystemLock.CreateNew(LockType.Enabled, LockType.Enabled)
};
StopAllCoroutines();
StartCoroutine(FlashCo());
}
private IEnumerator FlashCo()
{
if (hotspot.IsOn())
{
// REMOVE AFTER DEBUGGING!
mat.SetFloat("_OutlineWidth", outlineWidth);
mat.SetFloat("_OutlineDistortAmount", distortAmount);
playerHide.Interact();
textBackImage.color = tempColor;
mat.SetColor("_Color", tempColor);
mat.EnableKeyword("OUTBASE_ON");
textObj.text = hotspot.GetName(0);
yield return new WaitForSeconds(waitTime);
mat.DisableKeyword("OUTBASE_ON");
mat.SetColor("_Color", transparentColor);
textBackImage.color = transparentColor;
textObj.text = "";
playerShow.Interact();
}
}
}`
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
A script that allows for this can be found on the AC wiki here:
https://adventure-creator.fandom.com/wiki/Hold_input_to_flash_Hotspots
Thank you! I will check this out