Forum rules - please read before posting.

Walk Backwards with Mecanim Animator

I am trying to work out how to get walking backwards animations to play on my 3d direct controlled character. Is this what the "Vertical movement float" is used for on the character's player component?

I've tried to set up a simple blend tree using the "2D Freeform Cartesian" Blend Type that uses Speed and ForwardMovement for the parameters (Speed is the character's movement speed float, ForwardMovement is the vertical movement float), but I can only get him to walk forwards.

Advice or a visual example, if anyone knows of any, would be appreciated.

Comments

  • Is this what the "Vertical movement float" is used for on the character's player component?

    No, this is for the character's change in position along the y-axis.

    If you're only dealing with moving forwards and backwards, you don't need a 2D Blend Tree - 1D should be enough, mapped to the character's movement speed float parameter.

    This should be negative when moving backwards, so uncheck "Automate Thresholds" and assign the backward, idle, and forward animations only (run too, if appopriate). Uncheck "Automate Thresholds" and tailor to suit - but this in general isn't an AC topic, but one of Unity in general.

  • Thanks, with that, I have it working when I preview it in the animator just relying on the movement speed parameter (just using a 1D Blend Type).
    An issue remains however, in that I don't know how to get AC to trigger the negative speed value in order to use the backwards walk.

  • To allow a Direct-controlled player to move backwards, you need to set the Direct movement type field to Tank Controls.

  • edited September 28

    Okay, the problem I have though, is that my character is able to enter a "first person mode", in which "full body" character geometry is rendered, so you can look down and see that you're not just a floating camera. However, if I'm walking backwards, it still plays the forwards walk animation, as it is still camera relative instead of tank controls.

    Edit: Just remembered you told us about this in order to change the movement type.

    Thanks

  • OK, I see.

    Yes, in this mode the Move Speed float is speed only - it doesn't account for direction.

    Add this script to set to new parameters, ForwardSpeed and RightSpeed, to correct values:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class ReverseFPAnim : MonoBehaviour
    {
    
        private Animator _animator;
        private AC.Char character;
    
        void Start ()
        {
            character = GetComponent <AC.Char>();
            _animator = character.GetAnimator ();
        }
    
        void Update ()
        {
            float forwardDot = Vector3.Dot (character.TransformForward, character.GetMoveDirection ());
            _animator.SetFloat ("ForwardSpeed", character.GetMoveSpeed () * forwardDot);
    
            float rightDot = Vector3.Dot (character.TransformRight, character.GetMoveDirection ());
            _animator.SetFloat ("RightSpeed", character.GetMoveSpeed () * rightDot);
        }
    }
    
  • So this script is added to the character and these new parameters need to be added to the animator, with the Blend Type changed to 2d Cartesian (as it's now dealing with 2 parameters)?

  • Add the two parameters, but use them how you like. A 2D BlendTree would be appropriate if you wanted strafing animations, but you can stick to a 1D for the original issue (i.e forwards/backwards only)

  • Great, thanks again Chris.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!