Выдает две ошибки в untiy 2d
первая ошибка
MissingComponentException: There is no 'Animator' attached to the "alienBlue_stand" game object, but a script is trying to access it.
You probably need to add a Animator to the game object "alienBlue_stand". Or your script needs to check if the component is attached before usi**ng it.
UnityEngine.Animator.SetInteger (System.String name, System.Int32 value) (at C:/buildslave/unity/build/Runtime/Animation/ScriptBindings/Animator.bindings.cs:352)
Player.CheckGround () (at Assets/New Folder/Player.cs:55)
Player.Update () (at Assets/New Folder/Player.cs:23)
вторая ошибка
ArgumentException: Input Axis horizontal is not setup.
To change the input settings use: Edit -> Settings -> Input
Player.Update () (at Assets/New Folder/Player.cs:24)
Вот код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
Rigidbody2D rb;
public float speed;
public float jumpheight;
public Transform groundCheck;
bool isgrounded;
Animator anim;
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
CheckGround();
if (Input.GetAxis("horizontal") == 0 && isgrounded)
{
anim.SetInteger("state", 1);
}
else
{
Flip();
if (isgrounded)
anim.SetInteger("state", 2);
}
}
void FixedUpdate()
{
rb.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, rb.velocity.y);
if (Input.GetKeyDown(KeyCode.Space) && isgrounded)
rb.AddForce(transform.up * jumpheight, ForceMode2D.Impulse);
}
void Flip()
{
if (Input.GetAxis("Horizontal") > 0)
transform.localRotation = Quaternion.Euler(0, 0, 0);
if (Input.GetAxis("Horizontal") < 0)
transform.localRotation = Quaternion.Euler(0, 180, 0);
}
void CheckGround()
{
Collider2D[] colliders = Physics2D.OverlapCircleAll(groundCheck.position, 0.2f);
isgrounded = colliders.Length > 1;
if (!isgrounded)
anim.SetInteger("state", 3);
}
}
Помогите пожалуйста я только начал изучать.