Исправление ошибки в скрипте Unity2D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public KeyCode leftKey;
public KeyCode rightKey;
public KeyCode squatKey;
public KeyCode jumpKey;
public Animator animator;
void Start()
{
rb = GetComponent<Rigidbody2D>();
animator.SetFloat("Speed", 0);
}
void Update()
{
float moveAxis = Input.GetAxis(moveInputAxis);
if (moveAxis != 0)
{
animator.SetFloat("Speed", Mathf.Abs(moveAxis));
Vector2 newVelocity = rb.velocity;
newVelocity.x = moveAxis * speed;
rb.velocity = newVelocity;
if (moveAxis < 0)
{
transform.localScale = new Vector3(-1, 1, 1); //flip character if going left
} else if (moveAxis > 0) //if going right
{
transform.localScale = new Vector3(1, 1, 1); //set the local scale to be facing right //set the local scale to be facing right
}
} else { //if no input is detected then set speed to zero and play idle animation
animator.SetFloat("Speed", 0);
}
if (Input.GetKeyDown(jumpKey))
{
animator.SetTrigger("Jump");
rb2d.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
}
}
}
как их исправить?
Источник: Stack Overflow на русском