My characters walking is very messed up, I have been looking for an answer for 3 days and still no one is able to figure it out. My character doesnt not walk in the direction its facing or the direction i want it to go.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Character1AnimControl : MonoBehaviour
{
static Animator anim;
public float speed = 2.0f;
public float rotationspeed = 100.0f;
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationspeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Rotate(0, rotation, 0);//moved this line to before movement
transform.Translate(transform.TransformDirection(Vector3.forward * translation));//movement is now moving based on rotation
if (translation != 0)
{
anim.SetBool("IsWalking", true);
}
else
{
anim.SetBool("IsWalking", false);
}
}
}
But I also think the problem could be with the axis of my model…
Thanks