Hi,
This seems like it shouldn’t be too hard but I’m kind of stuck.
I’m not too familiar with Vectors so I’m a little confused. I’m using the angry bot’s texture fade script and I’m trying to modify it. I got it to fade when the player looks up, but it also fades when the player spins around at certain rotation angles. How can I make it so it only fades when looking up?
Here’s the code:
#pragma strict var cameraTransform : Transform; var glowColor : Color = Color.grey; private var dot : float = 0.5f; function Start () { if (!cameraTransform) cameraTransform = Camera.main.transform; } function Update () { dot = 1.5f * Mathf.Clamp01 (Vector3.Dot (cameraTransform.forward, transform.up) - 0.25f); } function OnWillRenderObject () { renderer.sharedMaterial.SetColor ("_TintColor", glowColor * dot); }
Or this? Sorry for the weird format, I use the code paste but it doesn’t work…
#pragma strict var target : Transform; var mistColor : Color = Color.grey; private var angle: float = 0.5f; var targetDir = target.position - transform.position; var forward = transform.forward; function Start () { if (!target) target = Camera.main.transform; } function Update () { angle = Vector3.Angle(targetDir, -transform.up) - 0.25f; if (angle < 90.0) renderer.sharedMaterial.SetColor ("_TintColor", mistColor * angle); } }