#Problem with raycasts and hitInfo.point.
1 messages · Page 1 of 1 (latest)
always send the code
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));
}
}
so what is this script attached to?
a gun
when i attached it to camera i could only look to left and right
if i turn on and off my camera in game everything works fine but then when i start the game again it doesnt work