I want to be able to Instantiate a object on another object coordinates, but it’s giving me this error,
Assets/BallSpawnerForLevels.js(53,35): BCE0024: The type ‘UnityEngine.Vector3’ does not have a visible constructor that matches the argument list ‘(UnityEngine.Vector3)’.
Don’t know how to solve this, can someone tell me how to correctly do this?
Error on this line:
Destroy(Instantiate(Ball, new Vector3(ballspawnlocation), Quaternion.identity), ballLifeTime);
WholeScript:
#pragma strict
var Ball : GameObject;
var ballTimer1 : float = 0;
private var ballSpawned = false;
var gameObjects : GameObject[];
var ballSpawn : GameObject;
var ballScript : BallScriptForLevels;
var Sound : AudioSource;
var paused1 : boolean;
var spawntime : int;
var ballLifeTime : int;
var ballspawnpoint : GameObject;
function Start()
{
paused1 = true;
Sound = GetComponent(AudioSource);
Ball = GameObject.Find("Ball");
if (ballScript == null)
{
ballScript = Ball.GetComponent(BallScriptForLevels);
}
}
function Update()
{
if (ballScript.gameOver == false && paused1 == false)
{
ballTimer1 += 1 * Time.deltaTime;
Debug.Log("AAAAA");
if (ballTimer1 >= spawntime && !ballSpawned){
SpawnBall();
ballTimer1 = 0;
ballSpawned = true;
}
}
}
function SpawnBall()
{
var ballspawnlocation = ballspawnpoint.transform.position;
yield WaitForSeconds(1);
Destroy(Instantiate(Ball, new Vector3(ballspawnlocation), Quaternion.identity), ballLifeTime);
Sound.Play();
ballSpawned = false;
gameObjects = GameObject.FindGameObjectsWithTag ("Avoid");
for(var i = 0 ; i < gameObjects.length ; i ++)
//Destroy(gameObjects*);*
var UnPauseAll = gameObjects*.GetComponent(BallScript);*
yield WaitForSeconds(0.1);
* UnPauseAll.paused = false;*
}
function Unpause()
{
* paused1 = false;*
}