So,
I’m trying to fire a raycast through the crosshair everytime the player shoots, and after that, spawing some particles.
I saw some examples in the forum, ried do get it work on my scrip, but i get an error everytime I change something on the script.
var ammo:int = 8;
var shells:int = 3;
var damage:int = 50;
function Update ()
{
if (Input.GetAxis ("Fire1") ammo > 0)
{
Shoot ();
ammo--;
}
}
function Shoot ()
{
var ray = Camera.main.ScreenPointToRay (crosshairScreenPos);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit, 5))
{
if(hit.collider.gameObject.tag=="enemy")
{
print ("Got ya!");
}
}
}
So, can anybody help me, please?