Question by
LJ727 · Dec 09, 2016 at 02:23 AM ·
javascripterrorarrayslicingsystem.type
I cant figure out why my array is causing the error 'System.Type' does not support slicing.
// JavaScript
//my array of spawn point values
var A1 = Vector3(20,0.05,0);
var A2 = Vector3(20,0.05,-5);
var A3 = Vector3(20,0.05,-10);
var B1 = Vector3(25,0.05,0);
var B2 = Vector3(25,0.05,-5);
var B3 = Vector3(25,0.05,-10);
// My array list
var SpawnPoints = Array["A1","A2","A3","B1","B2","B3"];
// My attampt to select 1 spawn point from the array to act as the enemy position
var enemyPosition = SpawnPoints[Mathf.floor(Mathf.random() * SpawnPoints.length)];
function Start ()
{
}
function Update ()
{
// my enemy at the moment is simply a cube, a new one with a rigid body should be instantiated at the enemy position
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent.<Rigidbody>();
cube.transform.position = Vector3(enemyPosition);
}
Comment