Question by
NLC_proxys · Mar 12, 2017 at 05:42 PM ·
animationanimatorrotation axis
how can i insert rotation with animation for my player?
Hi all, I have a question, i want do a player rotation with animation with this code? ps how i can do a jump with animation ever with this code. i have animation for left, right rotation and jump.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
public Rigidbody rb;
Animator m_Animator;
// Use this for initialization
void Start () {
m_Animator = GetComponent<Animator> ();
rb = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
var x = Input.GetAxis ("Horizontal") * Time.deltaTime * 150.0f;
var z = Input.GetAxis ("Vertical") * Time.deltaTime * 3.0f;
transform.Rotate (0, x, 0);
transform.Translate (0, 0, z);
if (Input.GetAxis ("Vertical") != 0 && Input.GetAxis ("Horizontal") == 0) {
m_Animator.Play ("Walk");
} else {
m_Animator.Play ("Grounded");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Using an Avatar locks Movement in Character When Animating 0 Answers
How can i stop my shooting animation after playing? 0 Answers
Pausing and resuming animations Unity 5.2 0 Answers
Animation Running Game 0 Answers
Having problems with making a Navmesh Agent stop and play an attack animation 0 Answers