3D Walk animation script errors
hey guys I am getting the following errors on my script;
Assets/Scripts/MoveToClickPoint.cs(37,3): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Assets/Scripts/MoveToClickPoint.cs(37,3): error CS0584: Internal compiler error: The method or operation is not implemented.
Assets/Scripts/MoveToClickPoint.cs(37,25): error CS0246: The type or namespace name
animator' could not be found. Are you missing an assembly reference? - Assets/Scripts/MoveToClickPoint.cs(17,16): warning CS0108:
MoveToClickPoint.camera' hides inherited member `UnityEngine.Component.camera'. Use the new keyword if hiding was intended
This is my script;
// MoveToClickPoint.cs
using UnityEngine;
using UnityEngine.AI;
public class MoveToClickPoint : MonoBehaviour
{
public Camera camera;
public NavMeshAgent agent;
RaycastHit hit;
private Animator myAnim;
private float dist;
void Start()
{
agent = GetComponent<NavMeshAgent>();
myAnim = GetComponent<animator>();
myAnim.SetBool("isRunning", true);
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
agent.SetDestination(hit.point);
}
}
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
{
agent.destination = hit.point;
}
dist = Vector3.Distance(hit.point, transform.position);
Debug.Log("Distance:" + dist);
if (dist < 1f)
{
myAnim.SetBool("isRunning", false);
}
Quaternion newRotation;
float rotSpeed = 5f;
Vector3 relativePos = hit.point - transform.position;
newRotation = Quaternion.LookRotation(relativePos, Vector3.up);
newRotation.x = 0.0f;
newRotation.z = 0.0f;
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, rotSpeed* Time.deltaTime);
}
}
Any help is appriciated.
Answer by hameed-ullah-jan · Oct 30, 2018 at 06:34 AM
in this line "myAnim = GetComponent();, you wrote "animator", replace it by "Animator"
Your answer
Follow this Question
Related Questions
Animator is not firing transitions. 0 Answers
NEED HELP ANIMATING PLAYER MOVEMENT 0 Answers
Using same animator for multiple game objects 0 Answers
How do I apply an animation to a sprite? 0 Answers
Animator blocking bone manipulation. 1 Answer