- Home /
I keep getting: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(float, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.
I keep getting "No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(float, UnityEngine.Vector3, UnityEngine.Quaternion)' was found"
I'm not quite sure where the mistake is. Where I need to pass a Vector3, I do, and so on with the Quaternion in the Instantiate function, yet I keep getting this error. Any help would be highly appreciated.
pragma strict
 var miProyectil: GameObject;
 var tiempoRecarga: float = 1f;
 var velocidadGiro: float = 5f;
 var tiempoPausa: float = .25f;
 var efectoBoca: float = .001f;
 var miObjetivo: Transform;
 var bocaPosicion: Transform[];
 var torreBola: Transform;
 var errorAmount: float = 2f;
 
 private var tiempoSiguienteDisparo: float;
 private var tiempoSiguienteMovimiento: float;
 private var rotacionDeseada: Quaternion;
 private var errorApuntar: float;
 
 function Start () {
 
 }
 
 function Update () 
 {
 
     if(miObjetivo)
     {
         if(Time.time >= tiempoSiguienteMovimiento)
             {
             CalcularPosicionApuntar(miObjetivo.position);
             torreBola.rotation = Quaternion.Lerp(torreBola.rotation, rotacionDeseada, Time.deltaTime*velocidadGiro);
 
             }
         if(Time.time >= tiempoSiguienteDisparo)
             {
         DispararProyectil();
             }
     }
         
 }
 
 function CalcularErrorApuntar()
         {
         errorApuntar = Random.Range(-errorAmount, errorAmount);
         }
 
 function EnemigoEntraRango(other : Collider)
     {
     if(other.gameObject.tag == "Enemigo")
     {
         tiempoSiguienteDisparo = Time.time+(tiempoRecarga*.5);
         miObjetivo = other.gameObject.transform;
         }
     }
 
 function CalcularPosicionApuntar(posicionObjetivo : Vector3)
     {
     var puntoApuntado = Vector3(posicionObjetivo.x+errorApuntar, posicionObjetivo.y+errorApuntar, posicionObjetivo.z+errorApuntar);
     rotacionDeseada = Quaternion.LookRotation(puntoApuntado);
     }
 
 function DispararProyectil()
     {
     audio.Play();
     tiempoSiguienteDisparo = Time.time+tiempoRecarga;
     tiempoSiguienteMovimiento = Time.time+tiempoPausa;
     CalcularErrorApuntar();
     
         for(laBocaPosicion in bocaPosicion)
             {
             Instantiate(miProyectil, laBocaPosicion.position, laBocaPosicion.rotation);
             Instantiate(efectoBoca, laBocaPosicion.position, laBocaPosicion.rotation);
             }
     }
     
 function EnemigoSaleRango(other: Collider)
         {
             if(other.gameObject.transform ==miObjetivo)
             {
                 miObjetivo = null;
             }
         }
         
Answer by aldonaletto · Sep 09, 2013 at 10:49 AM
The problem is in this line:
      Instantiate(efectoBoca, laBocaPosicion.position, laBocaPosicion.rotation);
efectoBoca is declared as float - definitely, you're not allowed to instantiate a float in the scene! What exactly are you trying to instantiate with this line?
Your answer
 
 
             Follow this Question
Related Questions
Error cannot convert quaternion to vector3 4 Answers
What is the problem with this code? 1 Answer
Help with Quaternions and Vector3s 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                