Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Invalid Token 'void' in class record struct or interface member declaration

Discussion in 'Getting Started' started by Luckydob, Apr 10, 2024.

  1. Luckydob

    Luckydob

    Joined:
    Apr 10, 2024
    Posts:
    1
    Hey, I'm pretty new to coding and couldn't figure this out through looking it up, could anybdoy help me? here is my code. Thank you in advance

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class NewBehaviourScript : MonoBehaviour
    {
    public static gamemanager instance;


    [SerializeField] private float time = 0.1f;

    [SerializeField] private bool isPlayerTurn = true;

    public bool IsPlayerTurn { get => isPlayerTurn; }

    void Awake()
    {
    if (instance == null)
    {
    instance = this;
    }
    else
    {
    Destroy(gameObject);
    }

    }
    Private void Start() {
    Instantiate(Resources.Load<GameObject>("Player")).name = "Player";
    }

    public void EndTurn()
    {
    isPlayerTurn = false;
    StartCoroutine(WaitForTurns());
    }


    private IEnumerator WaitForTurns()
    {
    yield return new WaitForSeconds(time);
    isPlayerTurn = true;
    }
    }
     
  2. DrDemencio

    DrDemencio

    Joined:
    Sep 2, 2022
    Posts:
    78
    The problem is in the line
    Private void Start() {
    , more specifically in the keyword Private which should be private.
    Using the code tag upload_2024-4-10_16-4-31.png to insert you code will make it much easier to read. Providing the error line would have also helped.
     
    halley likes this.