Hello. I Just came out from learning Java, not much experienced but I think I can make it, and I want to make an amazing Game using Unity, but I don’t know some facts of unity since I just started 4 days ago and all what I know its because I am watching YouTube videos, asking friends and searching in google.
Now, let’s say:
My game has various enemies, bosses, items and different characters to play with, every single of this will make a different thing. For example, if you take Item1, you can jump higher, if you take Item2, its a sword you can use just once and deal an enemy certain amout of damage. Enemy1 has different attacks as Enemy2, Enemy1 can Jump and make like exploding attacks, Enemy2 can’t jump and just make simple attacks and so with Enemy3,4,5,6,7,8. The idea here is to make a lot of different enemies (I have 21 planned this moment), A LOT of different items (I have 400+ in my mind) and some bosses (I dont have any)
My Question is:
How can I assing SpriteRenderers, or any component without making it public and selecting it in the Inspector?
Do I need to create a single prefab for each item, each playable character, enemy, and boss, then, make a lot of repeated variables, for example Health and MovementSpeed,
OR
For example:
Every character and enemies have its own attacks and variables, such as health, mana, dodge chance, critical chances, etc. and items too.
Can I create, lets call them Catalogs, codes called “CharacterAttacks”, “EnemyAttacks”, “ItemEffects”, “PlayerStats”, access to its methods, for example:
//Catalog of enemies attacks in "EnemyAttacks"
public void doAttack(int AttackID){ //If an enemy will attack, do so by calling this method from "Enemy.cs"
//todo process of the attack goes in here
}
//example of a script that ALL enemies will have
float Health = 100;
float MovementSpeed = 1;
float JumpHeight = 3;
float AttackSpeed = 1;
SpriteRenderer Sprite;
int EnemyID;
void Start(){
EnemyID = Random.range(0,100);
switch(EnemyID)
case 0:
//How can I obtain an sprite in my asset folder without making public SpriteRenderer Sprite and selecting it in the inspector?
break;
default:
//Same question here
break;
}
void Update(){
//MovementSystem
}
void OnTriggerEnter2D(Collider collider){
if (collider.gameObject.tag == "PlayerHitBox"){
//How can I access to the script "EnemyAttacks" if I dont make it component of any of my gameObjects in the scene?
}
}
and access to them every time I use attack1, every time I need to get the effect of an item, etc. instead of making prefabs and scripts for each one?
Or even go for OOP?
Which one is more practical and proffesional?
Which one is more efficient in performance?
Which one is better for multiplayer?
Another question is:
If I use a gameObject which is the player and have as component “PlayerControl” but there is just one script “PlayerStats” that have all the stats, for example JumpHeight , is this practical for local cooperative or even online multiplayer?
Thanks for reading this and I hope that you have a good day!
Please if you know the answers of my questions, feel free to post them and receive my thanks!