- Home /
Question by
NekoBro · Oct 21, 2019 at 08:53 PM ·
animations2.5dflipping
Flip 3D player in x-axis to face movement direction
I'm doing a 2.5 platform game and i have the movement for my 3d character, but i need to flip the character when he goes to the left to swap the animation.
using UnityEngine; using System.Collections;
public class PlayerController: MonoBehaviour { public float speed = 10.0f; public Animator anim;
void Update()
{
float translation = Input.GetAxis("Horizontal") * speed;
translation *= Time.deltaTime;
transform.Translate(0, 0, translation);
if (translation == 0)
{
anim.SetBool("running", false);
}
else
{
anim.SetBool("running", true);
}
}
}
this is my character code.
Comment
Your answer
Follow this Question
Related Questions
Why does Unity animator makes calling children's SetActive fail? 0 Answers
How do I edit keyframes of an animation 0 Answers
Layers not working after build,Layers not working after build. 1 Answer
Animation not playing correctly 1 Answer
Character Getting Caught on Colliders & Jump Animation Cancelled by Ground Check 0 Answers