Search Unity

Resolved error CS1001: Identifier expected

Discussion in 'Scripting' started by mkautsarfa, May 20, 2023.

Thread Status:
Not open for further replies.
  1. mkautsarfa

    mkautsarfa

    Joined:
    May 10, 2022
    Posts:
    3
    Hi i got this ontrigger function

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class testTrigger : MonoBehaviour
    6. {
    7.  
    8.     public logicManager wowKeren;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.        
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.        
    19.     }
    20.  
    21.     private void OnTriggerEnter(Collider collision)
    22.     {
    23.         string lokasi = "lautan";
    24.         wowKeren pindahLokasi(lokasi);
    25.     }
    26. }
    and this logic manager function


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class logicManager : MonoBehaviour
    7. {
    8.     public string lokasi;
    9.     public Text namaLokasi;
    10.  
    11.     void pindahLokasi(string berada)
    12.     {
    13.         lokasi = berada;
    14.         namaLokasi.text = lokasi;
    15.     }
    16. }
    somehow i keep getting error CS1001 on this line Assets\Scripts\testTrigger.cs(24,37).

    Can someone help me? Thank you.
     
  2. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    725
    Line 24: wowKeren pindahLokasi(lokasi); -> wowKeren = pindahLokasi(lokasi); (you forgot = sign)
     
  3. mkautsarfa

    mkautsarfa

    Joined:
    May 10, 2022
    Posts:
    3
    now it is showing me error CS0103: The name 'pindahLokasi' does not exist in the current context
     
  4. mkautsarfa

    mkautsarfa

    Joined:
    May 10, 2022
    Posts:
    3
    oh never mind, I got it. I was just really high, thank you.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    Well, high or not, the compiler doesn't care. :) Sometimes I even wonder if the compiler is high!!

    Here's the general process for errors:

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.
     
Thread Status:
Not open for further replies.