How to plug one gameobject into another in gameplay

Hey there! I’m very new to Unity and coding and I’m working on my first little game project.

My game revolves around placing character cards into locations and then the location and that character card deal damage to one another at a set rate (independent of one another) until one of them runs out of health.

I have two questions:

  1. Currently the location code has a serialized field to input the insertedCard scriptable object. I can do that manually myself through the unity interface just fine but how do I insert a gameobject into the field during gameplay through drag and drop?

  2. How do I properly reference the stats of the insertedCard within my location script? Snippet of my code below for example:

    private void GetCardStats()
    {
        if (insertedCard != null)
        {
           float cardInterval = insertedCard.GetComponent<CardStats>().cardInterval;
            float cardDamage = insertedCard.GetComponent<CardStats>().cardDamage;
            float cardHealth = insertedCard.GetComponent<CardStats>()._cardHealth;
        }
    }

    private void StartTimer()
    {
        GetCardStats();

        InvokeRepeating("TakeDamage", 1f, cardInterval);
        InvokeRepeating("DealDamage", 1f, locationTimerInterval);
        StartCoroutine(EndCombat());
    }

Thanks for any help you can offer! I’m sure these are extremely basic questions.

This is a pretty broad question as it covers multiple systems, of which themselves can be complicated in isolation.

Really the first question here is, do you have a working drag and drop system as of yet? If not, I would look for some tutorials in that domain, as they’ll likely answer your other questions once you understand the underlying principles.

Drag and drop system aside, you would have zones that, when something is dragged into it, check what type of object it is (or in the case of game objects, if it has specific component), and then do something with said object.