My player rigid body wont collide

complete beginner here, having a hard time finding this…
i have tried another script and player collisions works well on my walls…

are these functions not compatible with rigidbody or collision?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TouchMovement1 : MonoBehaviour
public float moveSpeed = 3f;

public Rigidbody2D rb2d;

private void FixedUpdate()

void TouchMove()
    if (Input.GetMouseButton(0))
        Vector3 _mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(_mousePos.x, _mousePos.y, transform.position.z);


@dansemur There could be many reasons why your object is not colliding. And it is probably unrelated to your script.

  1. Got to the editor and make sure your rigidbody2d is enabled and attached to a collider 2d. Both colliding objects must have 2D collider components if you want them to work with 2D rigidbodies.
  2. Make sure “is Trigger” is unchecked on both colliders.
  3. Test out your rigidbody2d with the object you want it to collide with before you add scripts to it.