I’ve been trying to find help for this for three days and still haven’t found any either it’s either to old or doesn’t work on my code, so here’s my code:
var TargetDistance : float;
var AllowedRange : float = 15;
function Update () {
if(Input.GetButtonDown("Fire1")) {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) {
TargetDistance = hit.distance;
if (TargetDistance < AllowedRange) {
hit.transform.gameObject.GetComponent.<Renderer>().material.color = Color.green;
}
}
}
}
I want to make it so that the RaycastHit only applies on a certain tag.
Unity some words we use for our code such as RaycastHit, it says incorrect spelling on your spelling.