I'm building a Raycast setup where game objects run code on click / touch.
if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, maxDistance, interactableLayers))
{
if (Input.GetButtonDown("Fire1"))
{
if (hit.collider != null)
{
currentInteractable = hit.collider.GetComponent<Interactable>();
Debug.Log(hit.collider.name);
}
}
I'm following a tutorial where I must use an Interface to configure OnClick Actions for each game object:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// public class Interactable : MonoBehaviour
// {
public interface Interactable
{
void onClickAction();
}
However, I'm receiving a bunch of errors! I can't add this Interactable script to my game object and receive the error: "Can't add script behaviour Interactable. The script class can't be abstract!"
I also see in the console: "'Interactable' is missing the class attribute 'ExtensionOfNativeClass'!"
Why is this happening?
MonoBehaviour-derived class that implements theInteractableinterface? \$\endgroup\$