#Problem with raycasts and hitInfo.point.

1 messages · Page 1 of 1 (latest)

raven kindle
#

Red dot is where i shoot

south vapor
#

always send the code

raven kindle
#

void Shoot()
{
RaycastHit hit;

    if(Physics.Raycast(transform.position, cam.transform.forward, out hit, range))
    {
        print("hit " + hit.point);

        Enemy enemy = hit.transform.GetComponent<Enemy>();
        if(enemy != null)
        {
            enemy.TakeDamage(damage);
        }

        Instantiate(impact, hit.point, Quaternion.LookRotation(hit.normal));
    }

       
}
south vapor
#

so what is this script attached to?

raven kindle
#

a gun

raven kindle
#

if i turn on and off my camera in game everything works fine but then when i start the game again it doesnt work