Hi guys. I watched brackey new tutorial on raycast but I cant get the raycast to rotate with the camera.
public float fireRate;
public float damage;
public float range;
public Camera fpsCam;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("Fire1"))
{
Shoot ();
}
Debug.DrawRay (transform.position, Vector3.forward, Color.green);
}
public void Shoot()
{
RaycastHit hit;
if (Physics.Raycast (transform.position,Vector3.forward,out hit, range))
{
Debug.Log (hit.transform.name);
}
}
I cant help myself because I teach programming to myself and the scriping API hasn’t helped.