Hellooo, UnityAnswers.
Currently, I'm making a script wherein it casts a ray ahead of the player checking if there's anything tagged "Active" within a small range. If there is, it disables the characters' abilities attached to a certain button, and makes said button open the door instead. The issue I'm having now is that once an Active object is found, I can't reverse the abilities getting disabled if the player moves away from the object.
The way I figure, I could get it to work if I could tell when the Ray isn't hitting anything, and reversing the disabling there. How would I do that? Or is there a better way?
The script that checks for an Active object ahead of the player:
static var canSkill = true;
static var canActivate = false;
function Update () {
var hit : RaycastHit;
if(Physics.Raycast (transform.position, transform.forward, hit, 2)){
if(hit.collider.tag == "Active") {
print ("Active");
canSkill = false;
canActivate = true;
}
}
}