How to make a character make different hitting animations with the same button?
hello, I have a question or problem, the thing is that I want to have 3 different animations of basic blows and I want each one to be done with the same button that I have assigned to it in the inputs, the thing is that when you hit the button (in this case 1) performs the animation of the first basic hit but in the animator does not perform the animation back to the static pose ... and after that they would be so that the other blows are made and that when doing the 3. it is restarted to the first one again, but I do not know how to write it in the script or if I have something to change in the animator, I would like to know how they would do it others. this is my script and as I have it in the unity the animator:
Hi, first of all: holy shit that is an incredible Skybox. If you have made this Skybox and / or models yourself, please add me on Discord: Drissy#2509. Or if you just want to talk too of course ;)
For the solution. What I'd do is keep a variable wherever you keep the Animator. As you want three states, you could simply do the following:
private int _animationIndex = 0;
// do other code
Animator.SetInteger("index", _animationIndex++);
Afterwards, adapt your Blend Tree to include the parameter "index" (or rename it to something more specific). Then you add this check to transition to one of the three respective animations. Hope this helps.
Answer by tormentoarmagedoom · Mar 29, 2020 at 01:54 PM
Hello.
Never post code as a image, use the code sampler button (or Crtl+K)
And regarding your question, you just need to store each animation in a array
Animation[] AnimationsList
Then use Random.Range to select one animation of the array.
Animation [Random.Range(0,AnimationsList.Length)]
Bye!
I don't know where that code sample button is ... and the CRTL + K doesn't work for me and what about the random.range where would you put it? I have been doing tests and I skipped errors no matter where I put it ...
Using this solution means you'd have to adapt your animations in run-time, you shouldn't have to do that. $$anonymous$$y reply will appear in one $$anonymous$$ute.
Answer by asiertroiti · Apr 01, 2020 at 02:23 PM
@tormentoarmagedoom I don't know where that code sample button is ... and the CRTL + K doesn't work for me and what about the random.range where would you put it? I have been doing tests and I skipped errors no matter where I put it ...
Your answer

Follow this Question
Related Questions
I need to kill bots when I shoot on them.I am not good on scripting, but I made my best. 1 Answer
[C#] Can't Control Movement While Jumping 0 Answers
how to get started with unity, while making a simple walking around games 1 Answer
How to open and view a .fpk file,How do I open a .fpk file to view the assets? 0 Answers
how do i take whats on one UI canvas and make it apear on another in real time(for a card game) 0 Answers