public class Gun : MonoBehaviour
{
public Rigidbody Bullet;
public int speed = 100;
public Transform spawn;
void Update()
{
if(Input.GetKeyDown(KeyCode.Mouse0)==true)
Spawn();
}
void Spawn()
{
Instantiate(Bullet,spawn.position,spawn.rotation);
Bullet.AddForce(Vector3.forward*speed);
}
}
and I dont know where my problem is
when I click on the mouse it create just the bullet but the bullet dosn’t move
where is my problem?
its not work’it do me a problem:
Assets/Gun.cs(18,21): error CS0266: Cannot implicitly convert type UnityEngine.Object' to UnityEngine.GameObject’. An explicit conversion exists (are you missing a cast?)
Theres steel 1 problem:
Assets/Gun.cs(18,21): error CS0266: Cannot implicitly convert type UnityEngine.Object' to UnityEngine.GameObject’. An explicit conversion exists (are you missing a cast?)