|
Post by 1337monkey on Jan 6, 2017 11:23:02 GMT
Didn't did any research on this, so asking you guys. Can you help me, or is there any topic or video tutorial on how to make random attack animations? For example, third attack animation is always different or smth.
|
|
|
Post by Invector on Jan 6, 2017 17:14:26 GMT
We had a example of random attacks on v1.3 but we forgot to add again on v2.0
simply add the vRandomAttackBehaviour script on your Sub-State Machine and set the Attack Count to be how many attacks this state will have, then inside the sub-state create transitions from the Entry state to each attack, and set the condition to be RandomAttack Equals > number
|
|
|
Post by G 4 greatness on Jan 7, 2017 13:29:49 GMT
please add a video on random attacks
|
|
|
Post by shadex on Jan 8, 2017 15:00:59 GMT
We had a example of random attacks on v1.3 but we forgot to add again on v2.0 simply add the vRandomAttackBehaviour script on your Sub-State Machine and set the Attack Count to be how many attacks this state will have, then inside the sub-state create transitions from the Entry state to each attack, and set the condition to be RandomAttack Equals > number I was looking for this Yesterday as well. In 2.0 there is no vRandomAttackBehaviour script. Would it be possible to paste a version of the script here?
|
|
|
Post by Invector on Jan 8, 2017 18:00:19 GMT
Sure, it's really simple
using UnityEngine; using System.Collections;
public class vRandomAttackBehaviour : StateMachineBehaviour { public int attackCount;
//OnStateMachineEnter is called when entering a statemachine via its Entry Node override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash) { animator.SetInteger("RandomAttack", Random.Range(0, attackCount)); } }
|
|
|
Post by shadex on Jan 9, 2017 5:06:29 GMT
Sure, it's really simple using UnityEngine; using System.Collections;
public class vRandomAttackBehaviour : StateMachineBehaviour { public int attackCount;
//OnStateMachineEnter is called when entering a statemachine via its Entry Node override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash) { animator.SetInteger("RandomAttack", Random.Range(0, attackCount)); } }
Ahh thank you a ton for this. Had to get rid of the current transitions to the other attacks to get it to work, But it's working well now.
|
|
|
Post by G 4 greatness on Jan 15, 2017 17:20:48 GMT
can u re add to 2.0
|
|
|
Post by shadex on Jan 17, 2017 3:02:10 GMT
Quick 2 second tutorial for those that are still having problems:
Step 1) Go to the animator on the enemy AI. only layers select FullBody - > Attacks -> Weak Attacks
Step 2) Single Click on Unarmed. click Add Behavior, add the random attack script from above. Step the number of random attacks you want where it says "Random Attack Count"
Step 3) Now Double Click to enter the Unarmed Sub-state
Step 4) Remove the transitions from A - > B, and B -> C so that all is left are the exit transitions
Step 4) add a transition for each attack (A, B, C, etc) with the condition RandomAttack Equals, and fill in the number (on Attack A put RandomAttack Equals 1 then on Attack B RandomAttack Equals 2, etc)
Step 5) Make sure there are the same amounts of attacks as your AttackCount on the Unarmed state.
There you go, you have random attacks.
(- Advanced -)
If you want to weight the random numbers, you can easily do so by raising the amount of attacks on the Unarmed state, and use the "<" or ">" operators to manipulate the out come.
AttackCount = 10 Attack A RandomAttack less then 5 Attack B Equals 6 Attack C Greater then 6
This would mean 1/2 the time A would be chosen, 1/10 the time B would be chosen, and 2/5ths of the time C would be chosen.
|
|
|
Post by Strider on Feb 28, 2017 3:45:54 GMT
Quick 2 second tutorial for those that are still having problems: Step 1) Go to the animator on the enemy AI. only layers select FullBody - > Attacks -> Weak Attacks Step 2) Single Click on Unarmed. click Add Behavior, add the random attack script from above. Step the number of random attacks you want where it says "Random Attack Count" Step 3) Now Double Click to enter the Unarmed Sub-state Step 4) Remove the transitions from A - > B, and B -> C so that all is left are the exit transitions Step 4) add a transition for each attack (A, B, C, etc) with the condition RandomAttack Equals, and fill in the number (on Attack A put RandomAttack Equals 1 then on Attack B RandomAttack Equals 2, etc) Step 5) Make sure there are the same amounts of attacks as your AttackCount on the Unarmed state. There you go, you have random attacks. (- Advanced -) If you want to weight the random numbers, you can easily do so by raising the amount of attacks on the Unarmed state, and use the "<" or ">" operators to manipulate the out come. AttackCount = 10 Attack A RandomAttack less then 5 Attack B Equals 6 Attack C Greater then 6 This would mean 1/2 the time A would be chosen, 1/10 the time B would be chosen, and 2/5ths of the time C would be chosen. i'm still a bit confused, the transitions with random attack are between A and B, B and C, or Entry and B, and Entry and C for example? Thanks!
|
|
|
Post by shadex on Feb 28, 2017 17:55:02 GMT
Quick 2 second tutorial for those that are still having problems: Step 1) Go to the animator on the enemy AI. only layers select FullBody - > Attacks -> Weak Attacks Step 2) Single Click on Unarmed. click Add Behavior, add the random attack script from above. Step the number of random attacks you want where it says "Random Attack Count" Step 3) Now Double Click to enter the Unarmed Sub-state Step 4) Remove the transitions from A - > B, and B -> C so that all is left are the exit transitions Step 4) add a transition for each attack (A, B, C, etc) with the condition RandomAttack Equals, and fill in the number (on Attack A put RandomAttack Equals 1 then on Attack B RandomAttack Equals 2, etc) Step 5) Make sure there are the same amounts of attacks as your AttackCount on the Unarmed state. There you go, you have random attacks. (- Advanced -) If you want to weight the random numbers, you can easily do so by raising the amount of attacks on the Unarmed state, and use the "<" or ">" operators to manipulate the out come. AttackCount = 10 Attack A RandomAttack less then 5 Attack B Equals 6 Attack C Greater then 6 This would mean 1/2 the time A would be chosen, 1/10 the time B would be chosen, and 2/5ths of the time C would be chosen. i'm still a bit confused, the transitions with random attack are between A and B, B and C, or Entry and B, and Entry and C for example? Thanks! For the enemy AI they should be entry to A, entry to B and entry to C. the conditions on those transitions should be RandomAttack Equals or RandomAttack > or <. This makes it so that any time an attack is triggered it has an entry to all of the animations of A B C and D. Then you further limit that to whatever number RandomAttack chooses. So it chooses the number, and then when the attack is triggered, it says "ohh lets pick this animation state" based on that number. You will see that the random number gets set like every second or so, but you have to wait for the attack to trigger it. I would show you a screen shot of one of my AI state tree's, but mine are a little confusing and over complicated lol
|
|
|
Post by Strider on Mar 2, 2017 5:42:34 GMT
Thanks! got it... os working really good, and my animator controllers are getting complex too!
|
|
|
Post by shadex on Mar 2, 2017 20:07:58 GMT
Thanks! got it... os working really good, and my animator controllers are getting complex too! Yea, it gets that way. Looks like a spider web after a while. I have a boss that has 1 weapon that has 9 attack combo's all weighted so the basic attack combo's go off more often then the special move combo's, with taunts in it, random idles, and about 30 attack animations. It looks incredibly good in a fight, but man, it gets confusing when your tweaking the numbers.
|
|