I currently have my player object set with a dynamic rigidbody and a box collider, and the object I want it to collide with just has a box collider.

The player is on the Player layer, and the object is on the Items layer.

This is the code I'm using that works for the collision, but I want the collision to work, but allow the player to pass through the object instead of bumping into it.

This is the code I'm using currently;

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

public class DialogueSpawn : MonoBehaviour
    public GameObject dialogueBox;
    private void OnCollisionEnter2D(Collision2D collider)

What am I missing to get this to work? I've been searching for two days for a solution to this problem and I'm not sure where to go from here, because this game is supposed to be a small project for figuring out layer collisions.

  • \$\begingroup\$ Is a trigger what you want? \$\endgroup\$
    – Tyyppi_77
    Nov 23 at 17:14
  • \$\begingroup\$ I'm trying to avoid triggers as I was encouraged to use layer collision for a reduction in runtime cost. Can layer collision not achieve the same effect? \$\endgroup\$
    – EvelynSays
    Nov 23 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.