G
G
GmDvlpr2019-11-18 17:47:30
Unity
GmDvlpr, 2019-11-18 17:47:30

Do you need classes in a unit?

Well, let's say we have a character, and there is a script for him, he has health, damage, etc. it's better for me to create several classes in one script and attach to the Persian, or better scripts with hp, damage, etc. attach not only to the Persian, but also to the enemies, or am I a fool, and should I do it differently?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaonosos, 2019-11-18
@GmDvlpr

If I understand the question correctly, then it is better, as I think, to create separate scripts for enemies and a hero, each of which will indicate health, damage, etc.

S
sstas, 2019-11-19
@sstas

You can make a base class into which you will add common logic from both the character and enemies, and then inherit from it, adding what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question