Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oneted_7 · Aug 13, 2018 at 08:38 AM · animationcharacter controllerattacking

how can make combat attack with different dmg?

hi i`m trying making a 2d game .i want make combat attack .attack after another attack after another attack.like a hack slash game ,like dmc. but my problem is when i click left click my first attack launch and after that when i try to click anotherone for next attack my anim will go to base anim and stop (my mean is unity will stop anim after launching first anim and next attack didnt launch) .i use this code for launching first attack and next attack and in animator i maked a transition from first attack to next attack .

  if (anime.GetBool("attack_1"))
      anime.SetBool("attack_1", false);

     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         anime.SetBool("attack_1", true);
     } 

also i dont have any idea about how can manage dmg for every fram of anime. can anyone talk about that?

i search in google and forum but no usefull .so pls help !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CaffeineAndCoffee · Aug 13, 2018 at 10:31 AM

For having different animations played when attacking in a quick succession, you can have an int, called animToPlay. Also make a float, called timeSinceLastAttack. When you press the attack button, increment animToPlay by 1, and set timeSinceLastAttack to 0. Reset timeSinceLastAttack to 0. If you press the attack button quickly, you will run through all of the animations.

 int animToPlay = 0;
 float timeSinceLastAttack = 0;
 float maxTimeBetweenAttacks = 1;
 
 void Update () {
      if (Input.GetMouseButtonDown(0)) {
           if (timeSinceLastAttack > maxTimeBetweenAttacks) {
                switch (animToPlay) {
                     case 0:
                          anim.Play("Attack 1");
                     case 1:
                          anim.Play("Attack");
                }
                timeSinceLastAttack = 0;
                animToPlay++;
           }
      }
 }

Can you go into further detail about damage?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image oneted_7 · Aug 13, 2018 at 01:28 PM 0
Share
   @Smart_Guy12 

i`m tried and maked it.

 void Update()
       {
      //attack_1
       if (anime.GetBool("attack_1"))
          anime.SetBool("attack_1", false);
      
      if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$ouse0))
          anime.SetBool("attack_1", true);
      
      //attack_2 
          if (anime.GetBool("attack_2"))
              anime.SetBool("attack_2", false);
            
          if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse1) && attacking_1)
              anime.SetBool("attack_2", true);
      //attack_3
      if (anime.GetBool("attack_3"))
          anime.SetBool("attack_3", false);
      if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse0) && attacking_2)
          anime.SetBool("attack_3", true);
  }

and maked transition from anystate to attack_1,attack_1 to(idle,attack_2),attack_2(attack_3,idle), attack_3 to idle.and i set 2 bool value attacking_1 attacking_2 .in recorder anime i change attacking_1 value to true in some frame i want .i did this for next attack . with those code every time is true and clicked will go for next attack. if have any question about this comment.

about dmg hmm.... my mean was dmg of sword change from every frame .example if sword of charachter is down no dmg if co$$anonymous$$g up get more dmg. first i didnt idea but after that plan for doing attack after attack , i think myb can set a float value and change it in frames .

but i have another problem now .when i click left click and after that right click for next attack i should get button down for 0.5 or it doesnt work .i change Get$$anonymous$$ey to Get$$anonymous$$eyDown but didnt solve. any idea????????

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

88 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to stop enemy from bumping into the player model but have it attack the player? 1 Answer

I need help with adding my character controller to a Character model 2 Answers

Merry Fragmas Character Controller for Unity 5 0 Answers

Does root transform (Y) work with Character Controller? 0 Answers

Localscale-flipped 2D character retains original rotation since 5.4 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges