Pickup is not clickable

My pickup is spawning appropriately, but the cursor does not change to my pickup cursor when I hover over it, and if I click on it anyway she just runs over it. Here’s my clickable pickup script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameDevTV.Inventories;

namespace RPG.Control
{
    [RequireComponent(typeof(Pickup))]
    public class ClickablePickup : MonoBehaviour, IRaycastable
    {
        Pickup pickup;

        private void Awake()
        {
            pickup = GetComponent<Pickup>();
        }

        public CursorType GetCursorType()
        {
            if (pickup.CanBePickedUp())
            {
                return CursorType.Pickup;
            }
            else
            {
                return CursorType.FullPickup;
            }
        }

        public bool HandleRaycast(PlayerController callingController)
        {
            if (Input.GetMouseButtonDown(0))
            {
                pickup.PickupItem();
            }
            return true;
        }
    }

    internal interface IRaycastable
    {
    }
}

This bit doesn’t belong. You should have a separate IRaycastable.cs which has the GetCursorType() and HandleRaycast() methods in it. I think the compiler is assuming you mean the blank IRaycastable, which is masking the real one.

Thanks! I was confused why it kept insisting I had to implement that since it already existed–turns out I spelled IRaycastable incorrectly when I made it in Core Combat–I have it spelled IRayCastable. So it couldn’t find it with the IRaycastable spelling and was insisting a new one had to be made.

1 Like

That happens from time to time. I’ve been caught in that scenario myself many times. As a rule of thumb, if you find that the compiler can’t find the Interface or class, and you intended to find one that exists, check the spelling before letting the editor create one for you. Smart as the editor is, on that particular issue, Intellisense is Intellidumb.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms