I am using this package of rigged animated characters: Low Poly Animated People | 3D Humanoids | Unity Asset Store
Each character has a prefab with a Nav Mesh Agent Script making them walking randomly around…
what I want is just to use one of those characters with a player script (make it walk around with the Keyboard). The Character is moving around in the scene when controlled by keyboard, but the animation is stuck in idle state.
What I did:
-Drag a prefab into the scene (“man-business”)
-remove “People_Wander Script”
-remove Nav Mesh Agent
+add a new script: “PlayerControl.cs”:
void update(){
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 camForward_Dir = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
Vector3 move = v * camForward_Dir + h * Camera.main.transform.right;
if (move.magnitude > 1f) move.Normalize();
move = transform.InverseTransformDirection(move);
transform.Rotate(0, turnAmount * RotationSpeed * Time.deltaTime, 0);
_moveDirection = transform.forward * move.magnitude;
_moveDirection *= Speed;
_animator.SetBool("Walk_Male", move.magnitude > 0); //not doing it at all
_moveDirection.y -= Gravity * Time.deltaTime;
_characterController.Move(_moveDirection * Time.deltaTime);
}
=> Character is moving around like expected => But in idle animation!
“Walk_Male” is not getting activated!
available animation states: