the code is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunScript : MonoBehaviour
{
private Camera PlayerCamera;
public GameObject robot;
void Start()
{
PlayerCamera = Camera.main;
}
// Update is called once per frame
void Update()
{
float shoot = 0.0f;
if (Input.GetAxis("Fire 1"))
{
shoot = 1.0f;
if (shoot > 0.0f;)
{
Ray gunray = new Ray(PlayerCamera.transform.position, PlayerCamera.transform.forward);
if (Physics.Raycast(gunray, out RaycastHit hitInfo, robot))
{
Destroy(robot);
}
}
}
}
}