- Home /
need help with animations for third person controller
Im working a on a Lord of the rings fantasy meets minecraft survival type of game (voxel survival) and i finished a character with a mixamo rig with a standing, running and jumping animation. I set up the character with in the Unity scene editor by replacing the capsule in the First person controller with my player model and I pulled the camera out of the model and made it third person. I also adjusted the model in the character controller collision capsule thing. Everything works perfectly but I just need to know how to attach the animations (running, standing/idle and jumping) with the character controller movements. Can someone please help thx :)
also can someone help explain what legacy is?
do you mean you want to be able to call the animations from the character controller movements script? or do you want to attach the animations to the charecter itself
I want the character to play the animation while its running and standing etc. Im using the first person controller and just want to attach the animation while its moving etc.
Answer by iast999 · Dec 16, 2013 at 05:41 PM
How about this? Your character will animated when run to left,right,front and back. But you need to make the animation first and make it legacy. When the character stand it will in "idle".
using UnityEngine;
using System.Collections;
public class PlayerAnimation : MonoBehaviour {
Animation animasi;
void Start () {
animasi = GetComponentInChildren<Animation>();
}
// Update is called once per frame
void Update () {
float v = Input.GetAxisRaw("Vertical");
float h = Input.GetAxisRaw("Horizontal");
if(v >0){
animasi.Blend("runFront");
}else if(v < 0){
animasi.Blend("runBack");
}else if(h > 0){
animasi.Blend("runRight");
}else if(h < 0){
animasi.Blend("runLeft");
}else{
animasi.Blend("idle");
}
}
}
Thanks for the script but im a bit confused here. I was trying to add the animation to the player but it said something in the inspector about legacy and you mentioned it above, what does it mean (ive been really struggling with animations in unity) I put a picture below so you can help me with what to do
also what component do i add to which part of the player : armature, parent, mesh
When you move your model 3D with the animation to unity, on the $$anonymous$$odel Import Setting(Click your model from Assets) choose Rig. On the Animation Type, choose Legacy and store in Root Node. This will make you can edit the 3D animation. You do not need to add any component, Animation will included to your 3D.
Answer by batubara · Jul 10, 2015 at 08:36 AM
using UnityEngine; using System.Collections;
public class PlayerAnimation : MonoBehaviour { Animation animasi;
void Start () {
animasi = GetComponentInChildren<Animation>();
}
// Update is called once per frame
void Update () {
float v = Input.GetAxisRaw("Vertical");
float h = Input.GetAxisRaw("Horizontal");
if(v >0){
animasi.Blend("runFront");
}else if(v < 0){
animasi.Blend("runBack");
}else if(h > 0){
animasi.Blend("runRight");
}else if(h < 0){
animasi.Blend("runLeft");
}else{
animasi.Blend("idle");
}
}
}