as i am going over my bugs wanted maybe to know how would you Handle the combos with different attacks
by clicking the mouse button to each combo to change
here is how i did it
it sometimes play the first attack twice so im trying to see how i can use the normalizeTime to use it better
isInCombo gets updated by an animation event so enable combo in the certain amount of time in the animation to get a click for light attack or heavy attack
then to see if light attack or heavy attack is pressed
and then switch to which attack
Fighter holds all the attacks light attacks and heavy attacks
if you want more info or other suggestions how to handle this let me know
It sounds like the issue is that sometimes the 1st attack is repeated instead of moving on to the combo attack. The setup is different enough that I’m going to have to make some assumptions about part of what’s going on.
Firstly, you have two different states which can be in direct conflict with one another. For instance, what happens if both the Light Attack button and the Heavy Attack button are pressed at the same time? My analysis of the code suggests that the stateMachine will attempt to switch to a new AttackState with a light attack value, then immediately switch to a new state with a heavy attack value. This can be rectified by resetting the opposing boolean in the OnHeavyAttack() and OnLightAttack() methods, for example:
and doing the same thing in isLightAttack.
It’s also advisable to short circuit HandleCombo if LightAttack is selected, then we don’t want to try to switch states in HandleHeavyAttack() at all. Changing HandleLightAttack() to a bool method will allow this:
Finally, you appear to have two competing mechanisms for determining whether to check for in combo… I don’t know what the conditions are for animatorHandler.isInteracting… is this a certain percentage of GetNormalizedTime?
In any event, you’ve already factored in the isInCombo, as isHeavyAttackPressed and isLightAttackedPressed cannot be set to true unless fighter.isInCombo. Testing for it again risks that isInCombo may now be false but the button was tested at the correct time.
We need to know when the animation is finished or nearly finished (or we’ll fall out of AttackState prematurely), so since we’ve already determined that the player pressed the button at the correct time, and we know that by the end of the animation we should no longer be testing for a combo, I would simply simplify that 2nd check in Executue (tick) to:
the is interacting i made to reset a bool in the animator when finished play the animation
because the GetNormalizedTime here isnt working for me
Because have different attacks and you want to switch when the animation is finished after logging that you pressed a button
i got all messed up with the light attack press and enabling combo withing the animation event lol
so i have enable colliders disable colliders and enable combo in the middle of animation and disable combo in the end of the animation
i dont understand how i can use here the GetNormalizedTime to help me with it
im not using it here at all
The problem im getting is that it returns to Locomotion too fast and then enter again
so my way of knowing if it finished is wrong
how can i use the GetNormalizedTime here i want to take out the isInteracting
I have the same issue with doing a roll dodge as using root motion
i also have to change the rotation of the character
so i am using the isInteracting to know that now im doing an action
its working good but with the precisions of doing attacks and combos sometimes you get in the first light or heavy attack 2 attacks very fast like a start of an attack then do another attack
Brian i found my problem with the isInteracting i will show you
so for me to know when i do some interacting ( some kind of action i have this )
I put a comment where i add that line now and all is good
public void PlayTargetAnimation(string targetAnim, bool isInteracting, bool useRootMotion = false)
{
if (useRootMotion)
{
animator.applyRootMotion = true;
}
else
{
animator.applyRootMotion = false;
}
this.isInteracting = isInteracting; // Here i forgot to add
animator.SetBool(interactingHash, isInteracting);
animator.CrossFadeInFixedTime(targetAnim, animatorDampTime);
}
so i have this method in animator handler and i made another layer for all my actions
like open a door open a chest attacking jumping and what ever
i reset the bool with OnStateExit of the animator
And in LateUpdate i get the bool to update isInteracting
i hope you understand what i mean lol :]
And again if you have a better more cleaner way then this im all ears
This is lets the GetNormalizedTimeRemaining tell the percentage of time left in the animation whether it’s Attack1, Attack2, or whatever. As long as the tag is Attack, the function will find it.
Here’s my slightly modified version of GetNormalizedTime() which is also handy for other types of actions:
My modification makes it so that you can put the method in the base class and pass the required tag to the method. I find it handy for things like Dodge and roll moves as well.
With the tag on the method, you can tell exactly what percentage of time is remaining in the animation. That’s what Normalized time is… it gives a number between 0 (just starting) and 1 (done). Now we don’t need to worry about setting bools and state, just check to see if (GetNormalizedTime(animator, "Attack") > .9f)
Sorry got you confused
I made another layer with all my actions which have different states like light attack 1 light attack 2 jump dodge etc
And there have an empty state that i send all my transitions to there
When it enter the state of empty after it does its action/attack/etc
It goes to the empty state and reset the bool isInteracting
So when you are doing an action you know you doing it
But anyway i will try do it with the normalizetime seems to have more control of the time of the animations
Just remember, if you’re running these animations on another layer, you need to pass that layerIndex in the the GetNormalizedTime() method… it’s likely that it wasn’t working for you because the states aren’t in the 0th (default) layer, but in the 1 layer, i.e.
setting my currentTarget to null my target in fighter gets updated when he hit a target
setting the currentAttack index so i can get from my List of AttackData the info
And plays the animation from the animatorHandler which now still has true for isInteracting which i change
so i need to do a refactor for that method