Kod wygląda tak:
using UnityEngine;
using System.Collections;
public class DrzewoRayCast : MonoBehaviour {
public int odleglosc = 3;
private Drzewo drzewo2;
private DrzewoGracz animacja;
void Update () {
RaycastHit hit;
Vector3 fwd = transform.TransformDirection (Vector3.forward);
if(Physics.Raycast(transform.position,fwd, cut hit, odleglosc))
{
if(hit.collider.gameObject.tag == "Drzewo")
{
Debug.Log("Drzewo przed nami");
drzewo2 = GameObject.Find(hit.collider.gameObject.name).GetComponent<Drzewo>();
animacja = GameObject.Find("axe").GetComponent<DrzewoGracz>();
if(Input.GetButtonDown("Fire1") && animacja.czyMogeUderzyc == true)
{
drzewo2.treeHP -= 1;
}
}
}
}
}
Unity wypluwa mi coś takiego:
Assets/script/DrzewoRayCast.cs(13,66): error CS1525: Unexpected symbol `hit'
Assets/script/DrzewoRayCast.cs(27,9): error CS8025: Parsing error