Hi there!
I’m new to unity and trying to program a simple 2D game to get myself engaged. I decided to change a float variable to update with the timer, so i added more code and threw it into the void update section of my code.
I’m not entirely certain that the code I changed works, but I wouldn’t know because suddenly I’m getting a " } expected" error on line 27 and an “end-of-file” expected error on line 40. Is there something screwy in the line of code I changed (line 28) that would cause this? It was throwing an error in its original spot (between line 8 and 9) about “method name expected,” which I figured was occurring because it was now in the wrong place.
Sorry if anything I said above is incoherent, I have many years of experience with scratch but nothing else, so the finer aspects of hand-written code are still lost on me. Thanks in advance!
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeployPanel : MonoBehaviour
{
public GameObject panelPrefab;
private Vector2 screenBounds;
public float xpos;
// Start is called before the first frame update
void Start()
{
screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
StartCoroutine(panelWave());
}
private void spawnPanel()
{
GameObject a = Instantiate(panelPrefab) as GameObject;
a.transform.position = new Vector2(Random.Range((-2f * screenBounds.x), (-0.2f * screenBounds.x)), screenBounds.y * -1);
xpos = a.transform.position.x;
GameObject b = Instantiate(panelPrefab) as GameObject;
b.transform.position = new Vector2((xpos + 26), screenBounds.y * -1);
}
void Update()
{
public float respawnTime = (1.0f * (1/(1+((0.05f)(GameObject.Find("Timer").GetComponent<Timer>().tick)))));
}
IEnumerator panelWave()
{
while(true)
{
yield return new WaitForSeconds(respawnTime);
spawnPanel();
}
}
}