when I use a OnCollisionEnter2D it isn’t triggered, here is my code
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator animator;
Vector2 movement;
// The Problem
private void OnCollisionEnter2D(Collision2D collision)
{
print("It Worked");
}
// Not the problem just my character controller
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);
}
void FixedUpdate()
{
rb.MovePosition(rb.position + movement.normalized * moveSpeed * Time.fixedDeltaTime);
}
}`
and here are some screenshots of the two objects that are supposed to collide
Edit : the code sample doesn’t get formatted for some reason