Different weapon behaviors on different enemies

Hey guys so i want to make weapons do behave differently with enemies. for e.g. i want sword to deal 100 damage to robots but axe 1 damage and axe 100 damage to zombies but sword 1 damage to them. is there any tutorials you can link below? Thanks!,Hey guys. so i want to make each weapon to deal different damage to enemies. for e.g. sword deals 100 damage do robot but axe does 1. how do i make this? is there any tutorials you can link down below? Thanks!

You can gain knowledge of this from just simple tutorials that go through OOP… I know Unity is redoing the engine to DOTS, but there isn’t as much in the way of docs or tutorials quite yet.


You could start out with a generic base class called Weapon and then get into your child classes from there (Sword and Axe):


public abstract class Weapon : MonoBehaviour
{
    protected float damageToFleshyEnemies;
    protected float damageToMetalEnemies;

    public abstract void Attack()
    {
        
    }
}

public class Sword : Weapon
{
    private void Start()
    {
        damageToFleshyEnemies = 1;
        damageToMetalEnemies = 100;
    }
}

public class Axe : Weapon
{

    private void Start()
    {
        damageToFleshyEnemies = 100;
        damageToMetalEnemies = 1;
    }

}

That’s just a basic broad idea and does not have any logic, but it’s a base setup to evolve with.