I want to add an collider automatically to the gameobject with the script.
When trying to attach the script to any gameobject in the hierarchy it’s showing this error message:
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
[RequireComponent(typeof(Collider))]
public class InteractableItem : MonoBehaviour
{
public enum InteractableMode
{
Description,
Action
}
[Header("Interaction Settings")]
public InteractableMode interactableMode = InteractableMode.Description;
public float interactionDistance = 5f;
[TextArea(1, 10)]
public string description = "";
private IKControl ikControl;
private void Start()
{
ikControl = FindObjectOfType<IKControl>();
if (ikControl != null)
{
ikControl.lookObjects.Add(transform);
}
}
public bool IsAction()
{
return interactableMode == InteractableMode.Action;
}
private void OnDestroy()
{
if (ikControl != null && ikControl.lookObjects.Contains(transform))
{
ikControl.lookObjects.Remove(transform);
}
}
}