Slower backwards animations


I am trying to get the player to move slower when going backwards, I have the animations setup ready but he is going the same speed as when hes moving forward. How would I go about making him move slower when pressing “s”, thanks in advance.

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

		private Animator anim;
		private CharacterController controller;

		public float speed = 600.0f;
		public float turnSpeed = 400.0f;
		private Vector3 moveDirection =;
		public float gravity = 20.0f;

		void Start () {
			controller = GetComponent <CharacterController>();
			anim = gameObject.GetComponent<Animator>();

		void Update (){

		anim.SetFloat("horizontal", Input.GetAxis("Horizontal"));

			if (Input.GetKey ("w")) {
				anim.SetInteger ("AnimationPar", 1);
			}  else {
				anim.SetInteger ("AnimationPar", 0);

			if(Input.GetKey ("s"))
			anim.SetInteger("AnimationPar", -1);


			if (Input.GetButtonDown("Jump"))
			else if(Input.GetButtonUp("Jump"))

				moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;


			float turn = Input.GetAxis("Horizontal");
			transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
			controller.Move(moveDirection * Time.deltaTime);
			moveDirection.y -= gravity * Time.deltaTime;

Try using anim.speed to alter the speed of the animation while moving backwards. Set anim.speed to 1 at the start of the Update loop (so you are playing back normally when not pressing “s”) and setting it to a value less than 1 in the if(Input.GetKey ("s")) block. This should make the character animate slower while the key is pressed, but normally at all other times. Notably, this is a relatively simple solution for your use case. If you are having multiple scenarios where you alter animation speed you may want to look out for that.

Hope this helps.