In the Unity learn section - survival shooter, I am getting an error shows the following error
Type "UnityEngine.Animation" does not contain a definition for "SetBool" and no extension method "SetBool" of type "UnityEngine.Animation" could be found. Are you missing an assembly reference?
I have checked the name of files and components.
Code
using UnityEngine;
public class PlayerMovement: MonoBehaviour
{
public float speed = 6f;
Vector3 movement;
Animation anim;
Rigidbody playerRigidbody;
int floorMask;
float camRayLength = 100f;
void Awake()
{
floorMask = LayerMask.GetMask("Floor");
anim = GetComponent();
playerRigidbody = GetComponent();
}
void FixedUpdate()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Verticle");
Move(h, v);
Turning();
Animating(h, v);
}
void Move(float h, float v)
{
movement.Set(h, 0f, v);
movement = movement.normalized * speed * Time.deltaTime;
playerRigidbody.MovePosition(transform.position + movement);
}
void Turning()
{
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit floorHit;
if(Physics.Raycast (camRay ,out floorHit, camRayLength, floorMask))
{
Vector3 playerToMouse = floorHit.point - transform.position;
playerToMouse.y = 0f;
Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
playerRigidbody.MoveRotation (newRotation);
}
}
void Animating(float h, float v)
{
bool walking = h!= 0f || v!= 0f;
anim.SetBool("IsWalking", walking);
}
}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)