In the first scene (grass scene), the player works fine in the grass scene, but inside the house, the player after any input the player moves back a bit.
The video of what happens - https://i.imgur.com/aHXwCR7.mp4
my player movement script is below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playeMovement : MonoBehaviour
{
//public Animator animator;
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator animator;
Vector2 movement;
public static playeMovement instance;
public string areaTransitionName;
public void Awake()
{
if(instance == null)
{
}
else
{
Destroy(gameObject);
}
instance = this;
DontDestroyOnLoad(gameObject);
}
public void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.y);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}