- Home /
How to specify to ignore a collision when three objects are colliding
Hi, im trying to get a character to pick up an object and be able to hold it and rotate it while moving. Inorder to do this I was trying to use the script shown below to allow the object to ignore my players collision, but because the held object is so close to my player I cant specify which objects I want the held object to ignore collision with. Is there any way to specify that I want my collider to pass through the player while not passing through another object (i.e. the floor) without moving the object further away from my player? thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GrabPassthroughManager : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Player")
{
Physics2D.IgnoreCollision(collision.gameObject.GetComponent<BoxCollider2D>(), GetComponent<BoxCollider2D>());
}
}
}
Your answer

Follow this Question
Related Questions
How to disable circle rolling when it hits collision's corner? 0 Answers
Composite Collider on Tilemap not really stopping player 0 Answers
Unable to detect collision in 2d game please help!! 1 Answer
Check collision above player with raycasthit2d array 1 Answer
How to the detect what side of the player is colliding with a object in a tilemap 2 Answers