Hello everyone, I’m new to unity scripting and I immediately encountered problem I could not solve alone. This is, in fact, my first script, so my understanding of scripting is shabby. I tried to use other similar scripts online as reference, but failed.
I’m trying to instantiate explosion made with Detonator to the position where ray from gun hits.
Error I’m getting is following: “Assets/assault rifle.js(13,12): BCE0023: No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Vector3)’ was found.”
var explosionPrefab : GameObject;
function Update () {
if(Input.GetButtonDown(“Fire1”)) {
var hit : RaycastHit;
var gunRange : float = 10;
if(Physics.Raycast(transform.position, transform.forward, hit, gunRange)) {
Instantiate(explosionPrefab, hit.point, hit.normal);
}
}
}