I found a 3d model in Asset Store and I want to use it in my project. But I don’t know how to make it change animations - the model came with Animation component (that has “Animation” and “Animations” properties that I cannot change with a script), but no Animator component, no Animator Controller and no Avatar. I tried to make and add an Animator Controller but I don’t know how to make an Avatar. The model is made with Unity 3.3.0. What is the typical procedure after importing it into a project to make it work?
What model are you referring to? Is it a humanoid type model 2 arms, 2 legs, or is it a quadruped or other type model?
The model is probably created for the legacy animation system. Either use the legacy animation system - or convert the model and all animations to a generic rig in the inspector, under rig and animation tabs.
It’s a humanoid model. I eventually got it to perform the attack animation with this script:
public Transform player;
private Animation anim;
private bool isIdle;
// Use this for initialization
void Start () {
anim = GetComponent<Animation>();
isIdle = true;
anim["Attack_01"].wrapMode = WrapMode.Once;
}
// Update is called once per frame
void Update () {
Vector3 rel = player.position - gameObject.transform.position;
if (rel.magnitude < 5 && isIdle)
{
gameObject.transform.LookAt(player);
anim.Play("Attack_01");
isIdle = false;
//Debug.Log("Attacking");
}
else if (rel.magnitude < 10)
{
gameObject.transform.LookAt(player);
gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, player.transform.position, 0.05f);
anim.Play("Walk");
}
else if (rel.magnitude > 5 && isIdle == false)
{
anim.Play("Idle_01");
isIdle = true;
//Debug.Log("Idling");
}
}
but I’m now facing another problem - when it walks towards the player it doesn’t move on the ground and walks on air instead. It has a rigidbody component with both UseGravity and IsKinematic checked. I also want it to turns towards the player smoothly instead of instantaneously. Should I ask in the scripting forum?
Did the model come with a controller?
Have you gone through the learning material on animation?
The model has no animator controller. I have watched the animation parts of Space Shooter and 2D Roguelike tutorials, but there’s always a chance I forgot to do some important step Also, in my project, the model is placed on terrain unlike in those two.