Hello, I need help with a certain problem I am having with Unity 5. I have created a raycasting script in C# that simply allows me to destroy a certain object under the tag, “Objects”.
I have also imported a custom UI cursor that I want the color changing of, through bool animations, when a certain object is being hovered over.
using UnityEngine;
using System.Collections;
public class CursorChange : MonoBehaviour {
public float distanceToSee;
RaycastHit hit;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
Cursor.visible = (false);
anim.SetBool ("hasHit", false);
}
// Update is called once per frame
void Update ()
{
if(Physics.Raycast(this.transform.position, this.transform.forward, out hit, distanceToSee))
{
if(hit.collider.tag == "Objects")
{
anim.SetBool ("hasHit", true);
}
}
}
}
There are no compiler errors from this script yet the desired results are still not showing. Can anybody help?