The ClickablePickup is not included in the inventory intergaration package

Hi! When i tried to intergrate to my project, the clickablepickup.cs is not included in the package. Can I use the script in this package https://cdn.fs.teachablecdn.com/p83DBQKZRbCQBx5puTEa


image

You can, but you have to be extremely careful not to include any other files from that package (as they’re incomplete scripts.
It’s best to use this one:

Assets/Scripts/Control/ClickablePickup.cs
using System.Collections;
using System.Collections.Generic;
using GameDevTV.Inventories;
using UnityEngine;

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;
        }
    }
}

Thank you! It worked. When I read the comment, I see a lot of people getting the same problem. I think it should have ClickablePickup.cs in the Lecture Resources to avoid that

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

Privacy & Terms