- Home /
Question by
chhetling · Jun 28, 2015 at 06:01 PM ·
error messagescript error
BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.GameObject, UnityEngine.GameObject)' was found.
i get the BCE0023 error and i cant find out why
//Variables
var ammo : int = 100;
var fireRate : float = 0.0;
var Effect : Transform;
var TheDammage = 100;
var muzzelflash : GameObject;
var ShootingPoint : GameObject;
private var nextFire : float = 0.0;
function Update()
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if(Input.GetButton("Fire1")&& ammo>0)
{
if (Physics.Raycast (ray, hit, 100))
{
}
if(Time.time > nextFire)
{
var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(particleClone.gameObject, 1);
hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
if(Time.time > nextFire)
{
nextFire = Time.time + fireRate;
GetComponent.<AudioSource>().Play();
//here's the problem
Instantiate(muzzelflash, ShootingPoint);
ammo -= 1;
}
}
if(ammo <= 30)
{
if(Input.GetKeyDown("r"))
{
ammo = 30;
}
}
}
Comment
Answer by tanoshimi · Jun 28, 2015 at 06:05 PM
Because, exactly as the error states, Instantiate() doesn't take two Gameobject parameters - it takes a Gameobject, a Vector3, and a Quarternion:
https://unity3d.com/learn/tutorials/modules/beginner/scripting/instantiate