Problem with hitInfo in Raycast.

So i have this script that is trying to find which star you’ve clicked on and then set some variables with it properties.

Move.js

    var moveSpeed = 1;
    var turnSpeed = 1;
    var sscale;
    var stempscale;
    var speed : String;
    var object : String;
    var rayLength;
    var d;
    var loc : Vector3;
    var obj1 : Transform;
    var obj2 : Transform;
    var yloc : Vector3;
    
    function Update () 
    {
    	if(Input.GetButton("Forward"))
    	{
    		transform.position += transform.forward * moveSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("Backward"))
    	{
    		transform.position += -transform.forward * moveSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("Left"))
    	{
    		transform.position += -transform.right * moveSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("Right"))
    	{
    		transform.position += transform.right * moveSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("rForward"))
    	{
    		transform.eulerAngles.x -= turnSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("rBackward"))
    	{
    		transform.eulerAngles.x += turnSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("rLeft"))
    	{
    		transform.eulerAngles.y -= turnSpeed * Time.deltaTime;
    	}
    	
    	if(Input.GetButton("rRight"))
    	{
    		transform.eulerAngles.y += turnSpeed * Time.deltaTime;
    	}
    
    // find your position	
    	yloc = transform.position;
    
    //for speed control
    	if (Input.GetButtonDown ("e")) {
    	moveSpeed = 1;
    	turnSpeed = 25;
    	speed = "Slow";
    	}
    	if (Input.GetButtonDown ("r")) {
    	moveSpeed = 5;
    	turnSpeed = 50;
    	speed = "Normal";
    	}
    	if (Input.GetButtonDown ("t")) {
    	moveSpeed = 10;
    	turnSpeed = 75;
    	speed = "Fast";
    	}
    	
    // for star selecting	
    	rayLength = 10;
    	if (Input.GetMouseButton(0)) {
//PROBLEM IS HERE -- (I have also tried it without " : RaycastHit" on the end) -- vvv    
    		if (Physics.Raycast(transform.position, -Vector3.forward , out HitInfo : RaycastHit , rayLength)) {
    			object = RaycastHit.transform;
    			obj2 = RaycastHit.transform;
    			loc = RaycastHit.transform.position;
    		}
    	}
    	d = Vector3.Distance(obj1.position, obj2.position);
    }
    
    
    function OnGUI ()
    {
    if(Input.GetButton("Dcontrols"))
    	{
    	GUILayout.Label("Speed: " + speed);
    	GUILayout.Label("Display Controls: Q" );
    	GUILayout.Label("Forward: UP Arrow");
    	GUILayout.Label("Backward: DOWN Arrow");
    	GUILayout.Label("Left: LEFT Arrow");
    	GUILayout.Label("Right: RIGHT Arrow");
    	GUILayout.Label("Rotate Up: W");
    	GUILayout.Label("Rotate Down: S");
    	GUILayout.Label("Rotate Left: A");
    	GUILayout.Label("Rotate Right: D");
    	}
    else{
    	GUILayout.Label("Display Controls: Q (Hold Down)");
    	GUILayout.Label("Speed: " + speed);
    	GUILayout.Label("Your Location: " + yloc);
    	GUILayout.Label("Star Name: " + object);
    	GUILayout.Label("D to Sun: " + d + "ly");
    	GUILayout.Label("Locaton: " + loc);
    	}
    }

But it returns the error:

Assets/STARS/move.js(79,80): BCE0044: expecting ), found ‘HitInfo’.

Assets/STARS/move.js(79,88): BCE0044: expecting ), found ‘:’.

Assets/STARS/move.js(79,90): BCE0043: Unexpected token: RaycastHit.

Assets/STARS/move.js(79,112): BCE0043: Unexpected token: ).

I just don’t get what is going on…

And when i remove it all together it has these errors:

Assets/STARS/move.js(80,45): BCE0020: An instance of type ‘UnityEngine.RaycastHit’ is required to access non static member ‘transform’.

Assets/STARS/move.js(81,43): BCE0020: An instance of type ‘UnityEngine.RaycastHit’ is required to access non static member ‘transform’.

Assets/STARS/move.js(82,42): BCE0020: An instance of type ‘UnityEngine.RaycastHit’ is required to access non static member ‘transform’.

Make sense because i dont have it…

So any suggestions??

Thanks in advance for your help.

Its probably just a lowercase that needs to be uppercase…

If you need to know anything else then tell me.

“Onwards and Upwards my friend!!!” - Doctor Whooves

var HitInfo : RaycastHit;
if (Physics.Raycast(transform.position, -Vector3.forward , out HitInfo, rayLength))

var HitInfo : RaycastHit;
if (Input.GetMouseButton(0)) {
if (Physics.Raycast(transform.position, -Vector3.forward ,HitInfo, rayLength)) {
object = HitInfo.transform.gameObject.name;
obj2 = HitInfo.transform;
loc = HitInfo.transform.position;
}}