Pickup Challenge Slight Modification to the Clickable Pickup

II know when importing the next sections it will overwrite my changes so I will have to do it again when we get to the final integration steps.

I made it so that when you clicked on it would require you to move to it, and used the collider to to pick up the item with the trigger enter.

Clickable Pickup

        private void OnTriggerEnter(Collider other)
        {
            if (!other.CompareTag("Player")) return;
            pickup.PickupItem();
        }
        #region Implemtation IRaycastable

        public CursorType GetCursorType()....

        public bool HandleRaycast(MonoBehaviour callingBehavior, RaycastHit hit)
        {
            Mover mover = callingBehavior.GetComponent<Mover>();
            if (!mover) return false;
            if (Input.GetMouseButtonDown(0)) mover.StartMoveAction(hit.point);
            
            return true;
        }

        #endregion

The change from PlayerController to MonoBehaviour was because when going through the RPG Core Combat section I used Assembly Definitions for each of the different Namespaces and ended up with circular dependencies with IRaycastable(RPGEngine.Control; moved this to RPGEngine.Core), WeaponPickup (RPGEngine.Combat), the Control Namespace already depended on the Combat Namespace when adding the Control Namespace to the Combat assembly definition may have been the other way around, it will be interesting what changes I will have to make in the files from the Zip folder when I go and integrate this into my project.

Edit: If I hade waited until getting to the Clickable & Run-over Pickups I would have known that this was a chalange. I will probably make an IAction Pickup when I get to the Integration portion, and move my IRaycastable back to the Control namespace, I believe that this is a better way to go in the end. Weapon Pickup (Hack) and the (Hack) implemented here was because at the time this was just throw away code.

I did something similar, moving the IHandleRaycast to Core, though I used GameObject instead of MonoBehaviour (same basic idea, abstracting away from Control)

Game Object works to. I only went with a Mono Behavior because the original was Player Controller, which just wasn’t working for me so I just went the next step up Player Controller is a Mono Behavior

1 Like

Privacy & Terms