I seem to be having some problems after converting a JS to C#, I used a Invoke to get the results i wanted but dont seem to work in c# for some reason, What i want to achieve is for the GetButton to be delayed by what ever value i set publicly, Any ideas suggestions? Thanks.
using UnityEngine;
using System.Collections;
public class RayCastTree : MonoBehaviour {
public int rayLength = 10;
private PlayerControl playerAnim;
public GameObject tree;
void Update (){
RaycastHit hit;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, fwd, out hit, rayLength))
{
if(hit.collider.gameObject.tag == "Tree")
{
tree = (hit.collider.gameObject);
playerAnim = GameObject.Find("Katana_Anim").GetComponent<PlayerControl>();
if(Input.GetButton("Fire"))
{
tree.GetComponent<TreeController>().treeHealth -= 1;
}
}
}
}
}