Search Unity

how to add damage amount to animations

Discussion in 'Getting Started' started by PRABHBIR123, Apr 23, 2017.

  1. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    I want to create a wrestling game and when a player press a button attack attack 1 animation should start when player press button attack 2 times attack 2 animation should start and both of the attack attack 1 and attack 2 should deal different damage to the enemy player. Till now I don't have any code please help.
     
  2. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Are you willing to learn codeing or just want a finished working code?
     
  3. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    finished code
     
  4. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    PM me for price /work
     
    DocJ likes this.
  5. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Sorry, but don't expect others to write the code for you. We'll help you learn, but we aren't making your game for you
     
    DocJ and Ironmax like this.
  6. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    Its very hard for me i have done everything else in my game but I am not able to code this if you can help you are most welcome
     
  7. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Well you're not gonna learn anything if you don't try it yourself, and people won't be writing your game for you, so might wanna start learning now whilst the problems are simpler
     
  8. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    It's hard for everyone. Many of us have either gone to school to learn programming or spent a significant amount of our personal time learning on our own in order to be able to do what we do. None of us were born knowing how to write code. You can do it. You choose not to. You've gotta push yourself to learn something... It doesn't just happen through osmosis.

    If you're that averse to learning a programming language, you can try using a visual scripting tool in Unity. This won't solve all your problems, as you'll still have to understand the Unity API enough to know what kind of things you want to be doing, and you'll still have to be able to think like a programmer to be effective.

    The C# language only has something like 75 keywords. And I'd wager half of those you'll rarely if ever need to use. How quickly do you think you could learn a spoken language that only had 75 words in it? The rest is just syntax and punctuation, which you'll be Googling for a while, but will eventually come naturally.

    Of course, maybe you don't actually care. Maybe you don't really want to make a game. That's something that only you can know, though.
     
    DocJ likes this.
  9. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    Oh thanks for your kind words I have learnt how to do that
     
  10. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    Yeah for sure.
     
  11. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Learning is a choice you make for your self. Finished code is not going to help you. However sometimes its good to
    look at codes other people have done. (when you do know the basic of things).

    Since your willing to learn. I be answering your post. There are 2 things here.
    Part 1: Animation sync with your input.
    to do this you should read more about IEnumerator, they be your friend when it comes to animation sync.
    You can then delay event and match them up to what you want to happen.

    Code (CSharp):
    1. IEnumerator AnimationAttack()
    2. {
    3.      // Play animation for 1 second
    4.    Damage(Damagedtype.Fire,100,"FireAttack","Blazeing fire at the target");
    5.      yield return new WaitForSeconds(1);
    6.     // What happens when animation is over
    7. }
    Part2: DamageType. To do this you should read about strong types, you make a class that is called Damage, where
    damage has its own propertise. You can also read about Interface and how to implement this type of pattern. (more advanced)


    Code (CSharp):
    1. public enum Damagetype
    2. {
    3.     Melee,
    4.     Range,
    5.     Magic,
    6.     Fire,
    7.     Ice
    8. }
    9.  
    10. public class Damage : MonoBehaviour {
    11.  
    12.     public Damagetype _Damagedtype;
    13.     public float DamageAmount;
    14.     public string DamageName;
    15.     public string DamageDescription;
    16.  
    17. }
    18.  
     
    Last edited: May 26, 2017
    BrandyStarbrite, Schneider21 and QFSW like this.