HarrisonO
HarrisonO

Reputation: 17

Adding unique functionality to each instance of a scriptable object

I am working on an AR Pokemon game in Unity for a university project. While I am not handling the AR component yet, I am stuck trying to implement unique functionality for each card I create.

I have a class called PokemonCard which inherits from CardBase which is a scriptable object.

using UnityEngine;
[CreateAssetMenu(menuName = "Card/Pokemon Card", fileName = "new Pokemon Card")]
public class PokemonCard : CardBase
{    
  
    [SerializeField]
    public PokemonMove[] Moves;

    public Energy Type;
    public Energy[] Weakenesses;
    public Energy[] Resistances;

    public PokemonCard evolvedFrom = null;
    [SerializeField]
    int maxHP;
    [SerializeField]
    int currentHP;
}

When I create a new Pokemon Card, I want to be able to assign it with functions that represent the moves available for the card. For example, I want a Hitmonlee card to have 2 moves, "Jab" which is represented by a function that does 40 damage, and "Punch" which is represented by another function that does 70 damage.

I cant seem to find any information on how I can attach these functions to the scriptable object so that they can be called. If you need further clarification I'm happy to provide it! If using scriptable objects is not optimal, please let me know if there's another data structure I can use to store all this information and allow unique functionality

Upvotes: 0

Views: 46

Answers (1)

Eli Blokh
Eli Blokh

Reputation: 12293

It would be best if you use MonoBenaviour for the implementation of functionality.

At the same time, you may keep the static data in a scriptable object and access it from MonoBenaviour.

Upvotes: 0

Related Questions