UNEXPECTED SYMBOL? I need help!

Assets/Scripts/WorldInteraction.cs(18,2): error CS1525: Unexpected symbol `GetInteraction’
How can I fix this?

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

public class WorldInteraction : MonoBehaviour {
    NavMeshAgent playerAgent;

    void Start()
    {
        playerAgent = GetComponent<NavMeshAgent>();
    }


    void Update()
    {
        if (Input.GetButtonDown (0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()
            GetInteraction();

    }

    void GetInteraction()
    {
        Ray interactionRay = Camera.main.ScreenPointToRay (Input.mousePosition);
        RaycastHit interactionInfo;
        if (Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
        {
            GameObject interactedObject = interactionInfo.collider.gameObject;
            if(interactedObject.tag == "Interactable Object" )
            {
                Debug.Log ("Interactable interacted");

            }
            else
            {
                playerAgent.destination = interactionInfo.point;
            }
        }
    }
}

Missing a ) at the end of the if block

I added the ) at the end, but it just adds 2 more errors

Well then, fix them, you cant ask us for help every time you get a compile error, it will take years to get stuff done that way. :smile:

2 Likes

Haha yeah, I know. I’m just kinda new to scripting.
I fixed it already.
but thank you for your help.

For future reference the forum has an entire section for scripting. Please make sure you have read where to post before you do so.

Ok

With compile errors there is usually something that will tell you where to look. And I’m not just talking Unity’s console. Usually you get some indication when viewing the script in Visual Studios or Monodevelop. You just have to find those red marks. There is also often a red line where your error is. Now, this is speaking from Visual Studios, mono may show errors differently.

But if you are absolutely stuck, you need to post the script and the errors from the console. Otherwise, it’s difficult to help you.

1 Like

Ok, got it. thank you.

shouldnt that be like
quotes around the 0 , and
IsPointerOverGameObject().GetInteraction()
missing the dot

… i thiiink thats whats wrong , right?

oooor? missing the semicolon after IsPointerOverGameObject(); ???
idk exactly whats going on … hardly used eventsystem myself…

IsPointerOverGameObject();
GetInteraction();

also, KITTY CAT!!! MEOW MEOW MEOW!!!

 if (Input.GetButtonDown ("0") && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject().GetInteraction();

i have same problem , how to fix?

well the error tells you the line, and then you just read and reread every letter in the line until you spot what is written wrong … whatever is not in accordance with C# syntax