- Home /
This question was
closed Dec 17, 2014 at 03:24 PM by
unimechanic for the following reason:
Duplicate Question
Question by
Villlgaer · Dec 16, 2014 at 07:55 PM ·
errorraycasthitcs0165
RaycastHit CS0165 Error
Hey I get this error every time but I don't know why: "Assets/Scripts/PickUp/BranchPickUp.cs(20,20): error CS0165: Use of unassigned local variable `hit'"
And here is script: using System.Collections; using UnityEngine;
public class BranchPickUp : MonoBehaviour {
BranchNumberBehaviour BranchNumber;
bool canhover;
GameObject Branch;
void Start () {
BranchNumber = GameObject.Find("NumberOfBranch").GetComponent<BranchNumberBehaviour>();
}
void Update () {
var fwd = transform.TransformDirection(Vector3.forward);
RaycastHit hit;
if(hit.distance <= 5.0 && hit.collider.gameObject.tag == "PickUp")
{
canhover = true;
if(Input.GetKeyDown(KeyCode.E))
{
BranchNumber.NumberOfBranches += 1;
}
}
}
}
Comment
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
; expected. Insert a semicolon at the end. 1 Answer
Script error help! 1 Answer
varification error in editor script 1 Answer