- Home /
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!
Answer by highpockets · Feb 11, 2021 at 06:28 PM
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.
Hi. If you found the correct answer, please mark you question as Closed(from the edit button). Thank you.
Your answer
Follow this Question
Related Questions
Trigger and ennemy damage 2 Answers
Creating a timer for combat (C#) 1 Answer
use ScriptableObject as player data (rpg combat) 2 Answers
i need help with my attack point 2 Answers
character melee combat problem 1 Answer