function Update ()
{
if (Input.GetButton("Fire1"))
{
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay(Vector3 (Screen.width/2, Screen.height/2));
if (Physics.Raycast(ray, hit, 100))
{
print("You fired at the "+hit.collider.gameObject.tag);
}
}
}
Hi i have this above script called shootBullet. I am reading the getting started with unity book and this script ment to say in the console You fired at the medpack or if i shoot at the gun or keys. But it only says You fired at the untagged. My objects do have tags though. So i don’t know what is going on. Please note it is from this book and i have been reading it over and over again. But still i get the same result.
I’m a beginner but looks like you are hinting an untagged object.
It can be the ground? terrain? the skybox? or other type of object. Ask to print the game object name.
It can be that you are hitting nothing?
Sorry i’m late replying but i already looked at the support for a solution but no one has submitted anything like this and i kepted going with the book and came up with another problem that the zombie does not follow the waypoints it just moves forward continuely and just goes through the walls. I think it maybe the problem with the animation but not sure
Edit: I decided to try another walk animation and it actually patrols the waypoint now so it was the animation after all.