Персонаж дёргается но не движется

Я делаю 2D rpg игру и персонаж перестал двигаться. Он дёргается но не движется. Когда игра запущена в сцене персонажа передвигаю он обратно телепортируется.

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class PlrContr : MonoBehaviour
{
    Rigidbody2D rb;
    Animator anm;
    public BoxCollider2D bc;
    GameObject touch;
    GameObject inter;
    public float speed;
    public Dialogue dia;
    public Camera camer;
    public SaveLocation save;

    // Start is called before the first frame update
    void Start()
    {
        anm = GetComponent<Animator>();
        rb = GetComponent<Rigidbody2D>();

        transform.position = save.savedPos;
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (!dia.isScrolling)
        {
            if (Input.GetKey(KeyCode.W))
            {
                anm.SetInteger("Face", 3);
                anm.SetBool("isWalking", true);

                bc.offset = new Vector2(0f, 0.22f);
                bc.size = new Vector2(0.18f, 0.55f);

                rb.velocity = new Vector2(0, speed);
            }
            else if (Input.GetKey(KeyCode.S))
            {
                anm.SetInteger("Face", 4);
                anm.SetBool("isWalking", true);

                bc.offset = new Vector2(0, -0.4f);
                bc.size = new Vector2(0.1f, 0.2f);

                rb.velocity = new Vector2(0, -speed);
            }
            else if (Input.GetKey(KeyCode.D))
            {
                anm.SetInteger("Face", 1);
                anm.SetBool("isWalking", true);

                bc.offset = new Vector2(0.15f, 0f);
                bc.size = new Vector2(0.2f, 0.6f);

                rb.velocity = new Vector2(speed, 0);
            }
            else if (Input.GetKey(KeyCode.A))
            {
                anm.SetInteger("Face", 2);
                anm.SetBool("isWalking", true);

                bc.offset = new Vector2(-0.15f, 0f);
                bc.size = new Vector2(0.2f, 0.6f);

                rb.velocity = new Vector2(-speed, 0);
            }
            else
            {
                anm.SetBool("isWalking", false);
                rb.velocity = new Vector2(0, 0);
            }
        }
    }

    private void Update()
    {
        if (!dia.isScrolling)
        {
            if (touch)
            {
                if (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.KeypadEnter))
                {
                    anm.SetBool("isWalking", false);
                    var ls = new List<string>(touch.GetComponent<Interact>().logue);
                    dia.list = ls;
                    dia.ScrollText();
                }
            }
        }
        camer.transform.position = new Vector3(transform.position.x, transform.position.y, -10);
    }

    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "interactable")
        {
            touch = collision.gameObject;
        }
        else
        {
            touch = null;
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "interactable")
        {
            touch = null;
        }
    }
}

Ответы (0 шт):