I want a gun that changes the position a little as if it was inaccurate. heres my script. also it doesn’t seem to be working
var Damage = 1;
var spread : float = 0.25;
var Cam : Camera;
private var lineTransform : Vector3;
private var startTransform : Vector3;
function Update ()
{
lineTransform = transform.position;
startTransform = transform.position;
var hit : RaycastHit;
var ray : Ray = Cam.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5,0));
Debug.DrawRay(startTransform, lineTransform, Color.red);
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast (ray, hit, 500))
{
hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
lineTransform = hit.point;
}
}
}