This the glow code when called makes the item glow(). But that is a one shot. I figured the Update should turn off the glow at the next update, but that is not happening.
using UnityEngine;
using System.Collections;
public class StoneScript : MonoBehaviour
{
Color brighter;
Color greenGrey;
Material myMaterial;
bool bright = false;
// Use this for initialization
void Start()
{
ColorUtility.TryParseHtmlString("#3E594CFF", out greenGrey);
brighter = greenGrey * Mathf.LinearToGammaSpace(0.8f);
myMaterial = GetComponent<Renderer>().material;
}
public void glow()
{
myMaterial.SetColor("_EmissionColor", brighter);
bright = true;
}
// Update is called once per frame
void Update()
{
if (bright)
{
bright = false;
myMaterial.SetColor("_EmissionColor", greenGrey);
}
}
}
Hmm... I'm using a script I found for an enemy patrol behavior that relies on NavMeshAgent to work, and it seems that it is NavMeshAgent that causes the problem. Maybe my patrol script is fucky? Thanks...
I have tried a couple of things (including what you said).
I take out the if (bright) all twelve stones (connected to stoneScript) go bright immediately.
Glow is being called by a rotating object that points at one of the 12 items at a time. If I cut the framerate to 1fps, I can watch each one go one at a time, but then never turn off.
The object calling glow is doing the following:
void Update()
{
RaycastHit hit;
Vector3 origin = transform.position;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
origin += fwd * (carLength / 2); // move sensor to front bumper
bool hitTest = Physics.Raycast(origin, fwd, out hit);
Debug.DrawRay(origin, fwd * hit.distance, Color.cyan, 0, true);
if (!Dispatcher.me.ready) return;
if (!Dispatcher.me.work) return;
if (hitTest)
{
GameObject target = hit.collider.gameObject;
StoneScript stone = target.GetComponent();
results.hitDistance = hit.distance;
results.hitID = target.name;
stone.glow();
}
}
Hmm... I'm using a script I found for an enemy patrol behavior that relies on NavMeshAgent to work, and it seems that it is NavMeshAgent that causes the problem. Maybe my patrol script is fucky? Thanks...
– Larsthedude