Trying to make dodge influenced by direction using combat third person movement type

zoicelols

Member
I am using the combat third person movement type. I don't understand how to make my character dodge in a specific direction based on which direction I'm holding since I can't create 4 different dodge abilities and attach my custom ability starter per direction on each of the 4 that I can't create. The system only allows for one dodge ability per character. Right now my character only uses my forward animation.
 
I don't understand how to make my character dodge in a specific direction based on which direction I'm holding
Im not sure if this is what you are looking for but...
This will add a force to your character based on your moving direction:
C#:
//Stronger force will be applied while running(holding shift):
AddForce(m_CharacterLocomotion.Velocity * force, m_Frames, false, true);
C#:
//Same force will be applied when walking or running:
AddForce(m_CharacterLocomotion.Velocity.normalized * force, m_Frames, false, true);

I recommend that you look at the Jump ability since its pretty similar to a Dodge ability.
 
I actually have force added to my animations through events. Although it is in a different format.

In the demo scene I copied everything on the dodge ability and animator parameters as well as adding the int data setter ability. Yet my character can't transition to anything but the forward dodge state. The int data was the only parameter that was different on the different directional dodges in the demo agility scene animator. Do you know what I might be doing wrong?

EDIT: I just figured out that I shouldn't have used int data setter. Just having the parameters in my animator worked.
 
Last edited:
Im not sure if this is what you are looking for but...
This will add a force to your character based on your moving direction:
C#:
//Stronger force will be applied while running(holding shift):
AddForce(m_CharacterLocomotion.Velocity * force, m_Frames, false, true);
C#:
//Same force will be applied when walking or running:
AddForce(m_CharacterLocomotion.Velocity.normalized * force, m_Frames, false, true);

I recommend that you look at the Jump ability since its pretty similar to a Dodge ability.
Okay now I'm thinking about using the method you describe, but I don't know where I would put the
AddForce(m_CharacterLocomotion.Velocity.normalized * force, m_Frames, false, true);

When I try to put that into my events it is all red under that format. This is what I have been using.

Code:
 public void DashForwardEvent(string F)
    {

        rb.AddForce(Transform.forward * dashForward);

    }

    public void DashRightEvent(string R)
    {

        rb.AddForce(transform.right * dashRight);
    }

The reason I say I want to try using your method is because I couldn't get the diagonal dodge transitions to work in the animator. I got the forward, backward, left and right to work perfectly. I'm assuming the transitions didn't work properly because leg index parameter was the only difference in each of the Forward Left/Right and Backward Left/Right dodge directions in the animator and my animations are just copied and rotated versions of the backward and forward animations I use for the dodge. Although I'm not sure. Maybe Justin could help me out on this one.
 
The reason I say I want to try using your method is because I couldn't get the diagonal dodge transitions to work in the animator.

I would create a blend tree if you want to play an animation based on your moving direction.
In the demo animator are 2 parameters (HorizontalMovement and ForwardMovement). You can use them to select the right animation in your blend tree.

Example:
  • You press W,A + dodge button and it will play your DodgeFwdLeft animation
  • You press W + dodge button and it will play your DodgeFwd animation
Here is an example blend tree (Combat Movement) from the demo animator. It selects the animation based on your movement input.
movementAnimator.PNG

Im not sure if this is the right approach, but that is how i would try it.
 
Top