Questions about structure of the project

Hi guys,

What I am trying to make is a 3D defense game and I am thinking about the efficiency and optimization of a project with a game setting that includes Orc, Elf, and Human races, each with their own attack types. For example, Humans use axes, guns, and swords, while Elves use magic for attacks.

I am seeking advice on how to structure the scripts, for example:

  1. ICharacter interface.
  2. Human Script.
  3. Elf Script.
  4. Orc Script.
  5. IAttack interface.

Additionally, could you please tell me whether it’s better to drag and drop particle effects for attacks into the character object’s inspector in the Unity editor, or if there’s a better approach.

1 Like

This is a hard one Honestly don’t know much , although i think you should look into Scriptable Objects ,
create a script called EnemyData and follow this structure below.

[CreateAssetMenu(fileName = "New EnemyType", menuName ="Enemy")]
public class EnemyData : ScriptableObject
{
    public string name;
    public float speed;
    public float damage;
}

and in the project manager you can create a file scriptable Objects , and a subfile EnemyTypes
and in EnemyTypes right click and create a "Enemy" at the very top and give it values ,
and in your enemy script you can reference the scriptable object like this.

public class Orc : MonoBehaviour

[SerializeField] private EnemyData enemyData;

private void Start()
{
   Debug.Log("enemyData.name");
}

and in the inspector drag the enemyType scriptable object in the "enemyData" reference, Orc in this case

hopes this helps , should work for what your doing a little bit better although there might be more promising results through inheritance which I’m afraid I don’t know much about.

About the Particle effect, you’re always going to need a reference to the particle effect, but if you really don’t feel like manually referencing it, you can create a ParticleSystem and in script say this for example

GameObject explosion = GameObject.Find("boom");
explosion.GetComponent<ParticleSystem>().Play();

hope this helps or work tbh. no errors so.