Error Code CS1519
I am atempting to create a random spawn script. All was working fine, until I recieved this error code:
Assets/Scripts/Game/randomSpawn.cs(8,27): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
If anybody could help me out, I would appreciate it!
Code:
using UnityEngine;
using System.Collections;
public class randomSpawn : MonoBehaviour {
public float amountOfSpawnPoints = 2;
public spawnPoint = 0;
private static Vector3[] spawnPos = new Vector3[amountOfSpawnPoints];
// Use this for initialization
void Start () {
spawnPos[0] = Vector3(10,10,10);
spawnPos[1] = Vector3(20,20,20);
spawnPos[2] = Vector3(30,30,30);
SpawnObject();
}
// Update is called once per frame
void Update () {
}
public void SpawnObject() {
spawnPoint = Random.Range(0, amountOfSpawnPoints - 1);
Instantiate(spawnObj, spawnPos[spawnPoint], Quaternion.identity);
}
}
Answer by Landern · Dec 16, 2016 at 05:01 PM
Line 8, you didn't declare what type of variable this is instead you set the access modifier(public) and the name to 0. If it's meant to be an int(no floating point) then:
public int spawnPoint = 0;
if it should be a float or something else make sure you put the type after the access modifier(again after public)
Your answer
Follow this Question
Related Questions
How to fix this invalid token issue?Im new and wanted to learn what this code executes. 1 Answer
Unity created huge editor.log file 0 Answers
error CS0101: The namespace `global::' already contains a definition for `PlayerMotor' 1 Answer
I cant figure out these errors 0 Answers
My map turns blue red and green always! 0 Answers