I cannot pick up my weapon

I can swap unarmed and armed. However, I cannot pickup weapons. my script seems fine, I added in a collier and rigidbody and nothing. Any suggestion :slight_smile: using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace RPG.Combat
{
    public class WeaponPickup : MonoBehaviour
    {
        [SerializeField] Weapon weapon = null;
    
        private void OnTriggerEnter(Collider other) 
        {
            if (other.gameObject.tag == "Player")
            {
                other.GetComponent<Fighter>().EquipWeapon(weapon);
                Destroy(gameObject);
            }
        }

    }
}

Are there any error messages in the console?

Does the gameObject get destroyed when you run over it?

Is the collider set as Is Trigger?

There are no errors in the console. The trigger is set and the gameObject does not destroy.

Let’s put this in the beginning of the OnTriggerEnter:

Debug.Log($"{other.gameObject.name} has triggered {name} - Tag = {other.gameObject.tag");

I think that debug.log is missing a parenthesis

im not getting a debug log either in the console

Yep, that’s what I get for typing these things out on the fly, sorry about that.

Do you have a capsule collider on the Player?

no

Without a capsule collider, the player can’t trigger… both objects need a collider, and one of those two objects must have a Rigidbody

that worked thanks

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

Privacy & Terms