NullReferenceException: Object reference not set to an instance of an object не получается исправить
Выбивает ошибку `NullReferenceException: Object reference not set to an instance of an object` в 2 местах
На этих строках находиться код rb.velocity = new Vector2(speed, rb.velocity.y); anim.SetBool("isJumping", false);
Не как не могу исправить ошибку
public float speed;
public float jumpForce;
public float normalSpeed;
private Rigidbody2D rb;
public Transform feetPos;
private bool facingRight = true;
private bool isGrounded;
public float checkRadius;
public LayerMask whatIsGround;
private Animator anim;
public void FixedUpdate()
{
rb.velocity = new Vector2(speed, rb.velocity.y);
{
anim.SetBool("isRunning", true);
}
}
public void OnButtonUp()
{
speed = 0f;
anim.SetBool("isRunning", false);
}
private void start()
{
speed = 0f;
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
public void OnLeftButtinDown()
{
if (speed <= 0f)
{
speed = -normalSpeed;
transform.eulerAngles = new Vector3(0, 180, 0);
}
}
public void OnRightButtinDown()
{
if (speed >= 0f)
{
speed = normalSpeed;
transform.eulerAngles = new Vector3(0, 0, 0);
}
}
private void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);
if (isGrounded == true)
{
anim.SetBool("isJumping", false);
}
else
{
anim.SetBool("isJumping", true);
}
}
public void OnJumpButtonDown()
{
if (isGrounded == true)
{
rb.velocity = Vector2.up * jumpForce;
anim.SetTrigger("takeOf");
}
}
}