I'm trying to follow an rpg tutorial but the script to walk where clicked gives me an error:
error CS1525: Unexpected symbol `class'
Here is the c# code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WorldInteraction : MonoBehaviour
{
UnityEngine.AI.NavMeshAgent playerAgent;
void Start()
{
playerAgent = GetComponent();
}
void Update()
{
if (Input.GetMouseButtonDown(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;
}
}
}
}
↧