Raycast from secondary camera


What I am trying to do is create a script that grabs an object by raycasting from a camera embedded within an object. I was trying to restrict it so that it would only effect objects with a specific tag. In this case it is used for a vacuum nozzle. The script I have currently is below but it is getting an error originating on line 5 saying no appropriate version of “UnityEngine.Physics.Raycast” for the argument list ‘\UnityEngine.Vector3)’ was found. So is there a more efficient way to write this code to accomplish this or is there a resource I can look at to help me write a better version of this code?

Thanks in advance for you help.


So thanks to seeing a little more of the syntax I have changed by code to the below. Although one problem still persists and that is that I cannot get the ray to read objects with the specified tags. Is there something that needs to be done or should I be able to import fbx files into Unity and assign them their tags? So far doing this has resulted in the code printing not working. Is there some step that I for either tagging the objects or within my syntax?

var vacRange = 30.0;

function Update() {

if (Input.GetKeyDown(KeyCode.E)){
	var hit : RaycastHit;
	if(Physics.Raycast(transform.position, transform.forward, hit, vacRange)) {
    	print("hit something");
    		print("hitting food");
    		print("not working");


Physics.Raycast needs more arguments than just position, check the manual