Heal move JRPG // Need help with tag.

Hey guys, SO i’m coding a sort of turn based rpg right, now I am trying to have cure moves have a unique equation here so i’m avoid the easy way out of having them just do negative damage. So what I’m having trouble with here is…

…How can I call to an object that is being chosen in an instance using a tag.

I’ll explain further in some code I wrote below.

So pretty much he, I wanna have it so when the move has the tag “Health” it performs a different equation.

What can I do to have my code recognize something like that?

    void DoDamage()
    {
        float randValue = Random.value;
        if(CSM.PerformList[0].chosenAbility.f
        {

        }
        if (randValue < .80 - computer.currentLuck)
        {
            float calc_damage = computer.currentPower + CSM.PerformList[0].chosenAbility.abilityDamage;
            PlayerToEngage.GetComponent<PlayerStateMachine>().TakeDamage(calc_damage);
            Debug.Log("Computer Landed Hit");
        }
        else
        {
            float calc_damage = computer.currentPower + CSM.PerformList[0].chosenAbility.abilityDamage;
            PlayerToEngage.GetComponent<PlayerStateMachine>().TakeDamage(calc_damage);
            Debug.Log("Computer Landed Crit");
        }
    }

Thanks for any insight, this community has done nothing but raise me up and inspire me to push my boundaries. Hope I can learn something with this challenge too. Resources are welcome.

Just generally speaking, since you have a method named .TakeDamage()… wouldn’t you just clone that over to something that is named .TakeHealing() and call that instead?

As far as “tags” go, I’m not sure how to answer your question. In Unity, a tag is a specific single property that is part of a GameObject. There is only a single tag on a GameObject. Nothing else in Unity has tags, but as a convenience, Components have a shortcut link called .tag that is actually a shortcut to the tag that is on the GameObject that this Component is attached to. In other words, all Components (Monobehaviors or whatever) on a GameObject all share the same tag that the GameObject does.

1 Like

I see what you’re saying, and I think that’s a great idea. Although I guess my question here would be how can I get the game to tell the difference between which action to perform?

Hey man just as an update, I was able to figure it out. Took some creative work but worth the effort.

1 Like