hello sir i need help i am creating a game, my first game, the main character is a goat its a 2d game , i want to add enimes as wolf and add a attack animation of goat with his throns but i want only the enimies get attacked only if the player attack from behind can anyone tell me how to do it pleaseeee,
and one thing also
i want to add my native voice with charcters like it happens if a player goes to some character and intract with him so i want voice to get started
please help i am 14 years old i want help
if i am unable to make this game my father would never allow me to do it again
i love game making but i
I didn’t actually understand the sound part, but for the attack from back you can compare your player’s transform.position.x and the enemy’s transform.position.x, and check if the enemy’s sprite is flipped or not
Like
public bool CanAttack = false;
public SpriteRenderer enemysprite;
public Transform enemy; //you must tell your script who your enemy is
void Update()
{
if (enemy.position.x < player.transform.position.x && enemysprite.flipX == true || enemy.position.x > player.transform.position.x && enemysprite.flipX == false)
{
CanAttack = true;
}
}
And that depends on how you are gonna make your attacks, after that you must make it so that the attacks only work if your bool “CanAttack” is true
thanks for replying i will try these codes, and by sound i mean like for example in that there is a shop and if my player goes to shop how will i intract with shopmen and i want to add like when player click enter to interract the shop man star spleaking the sound which i recorded
Oh, for that, there is a lot of tutorials of how you make interactions with your player, you can make some really flexible codings that will allow your player to read dialogues, enter shops, activate buttons, etc, just search about “Dialogue System Unity” in youtube and I’m sure some of the videos will help you.
Once you get your player interactions ready, you can just apply the audio source on the events you want the sounds to play.