To develop a animator using unity with C# prgram and move the animator.
Download 2 crouch idle from maximo 3d. Drag it and drop it in unity asset.
Select one crouch and in the inspector choose rig-> Animation type (humaniod) and then click update.
Perform the step 2 for another crouch
Select one crouch and in the inspector choose Animation-> Root transform rotation-> Based upon (original) and check the Loop Time and click apply
Perform the step 4 for another crouch
Drag one crouch, put it in hierarchy and name it as Player.
In the Player inspector we have Animator. Right click in Assets-> create -> Animator Controller (name it as IdleToCrouch)
Drag the IdleToCrouch to the Controller option under the Animator in the inspector. Click that IdleToCrouch , a window opens and select parameter tab , create 2 parameter, InputX and InputY
Select the another crouch and attach with Entry button and name it as movement. Right click it and choose create blend tree.
Click the movement button, blend tree opens. Choose InputY in parameter and under the motion click โ+โ sign and choose add the motion field twice.
Drag the second crouch and put it motion field, then drag the first crouch and put it in the another motion field.
Uncheck the automata threshold and change the values -1 and 0 in first column( priority for the crouch). Create a C# file and name it as IdleToCrouch, drag it to the player
Download a walking crouch from maximo 3d and drag it into unity. In the inspector select rig-> animation types(humanoid) -> Apply
Select the crouch and in the inspector choose Animation-> Root transform rotation-> Based upon (original) and check the Loop Time and click apply
In blend tree, in blend type choose (2D Freedom Directional), parameter (InputX, InputY) , one crouch (0,-1,1) and walking (1,0,1). Bring the camera under the player.
Developed By: Jeeva MS
Reg No: 212221230040
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player_controller : MonoBehaviour
{
public Animator animator;
public float inputX;
public float inputY;
// Start is called before the first frame update
void Start()
{
animator = this.gameObject.GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
inputX = Input.GetAxis("Horizontal");
inputY = Input.GetAxis("Vertical");
animator.SetFloat("inputX", inputX);
animator.SetFloat("inputY", inputY);
}
}
Thus, the animator was successfully developed in unity engine with the C#.