I am trying to make a gun that shoots the bullets i made. Yet, when i finish the script i get one error…which is
“Assets/GUN/Shoot1.js(14,34): BCE0023: No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(UnityEngine.Transform, UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Quaternion)’ was found.”
Instantiate, for those who don’t know, is for cloning objects. ![]()
Also this is the script…
#pragma strict
function Start () {
}
public var Bullet : Transform;
public var bulletSpeed : float = 6000;
function Update () {
if (Input.GetButtonDown(“Fire1”)) {
if (!Bullet || !bulletSpeed){
Debug.Log(“[Shoot] ‘Bullet’ or ‘bulletSpeed’ is undefined”);
} else {
var bulletCreate = Instantiate(Bullet, GameObject.Find(“SpawnPoint”),transform.position, Quaternion.identity);
bulletCreate.rigidbody.AddForce(transform.forward * bulletSpeed);
}
}
}