So i have the problam, that when i walk in to an other objects collider(in my video the tree) then my Player is glitching. On the tree i have a Polygon Collider 2D and this is my movement script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class MovementScript : MonoBehaviour
{
public float speed = 5f;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector2 movement = new Vector2(horizontal, vertical);
movement = Vector2.ClampMagnitude(movement, 1f);
rb.velocity = movement * speed;
}
}