Hello I have created a script that creates a raycast from a camera to seek out an object with a specific tag, although now I want to find a way to manipulate the object once it is found. In this case it is for a vacuum script, where I am getting stumped is how to save the object to a single variable so that it will be easier to manipulate it. My intentions was to save it to the target variable so that I can manipulate the object from there. So any suggestions for how best to do this? I placed the code I wrote up below and thanks in advance to anyone who replies.
var vacRange = 30.0;
var target: Transform;
function Update(){
if (Input.GetKeyDown(KeyCode.E)){
var hit : RaycastHit;
if(Physics.Raycast(transform.position, transform.forward, hit, vacRange)) {
print("hit something");
if(hit.transform.tag=="Food"){
print("hitting food");
}else{
print("not working");
}
}
}
}