Question by
Beta4 · Feb 22, 2019 at 05:47 PM ·
collider2dnot workingignore collisionsignore objects
IgnoreCollision not working at all!!! Please help!
I have created a simple script that is on this object which spawns from another script. I want this object with this script to just go through and ignore the player object with the "Player" tag but it doesn't do that- instead destroys the player object and goes through the player unharmed which is fine. I just want the player object not to be phased as this object passes through it. Any help would be appreciated. Thanks again.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ignoring2DCollisionScript : MonoBehaviour {
public GameObject player;
private void Start()
{
}
private void Update()
{
}
private void OnTriggerEnter2D(Collider2D collider2D)
{
if (collider2D.CompareTag("Player"))
{
Physics2D.IgnoreCollision(player.GetComponent<CircleCollider2D>(), this.GetComponent<CircleCollider2D>());
}
}
}
Comment
Your answer
Follow this Question
Related Questions
OnCollisionEnter 2d not working 0 Answers
Tilemap collider 2D not working 2 Answers
Possible bug whith 2d Collider Editors,Problems with collider editor 0 Answers
Jump off 2D platforms Smash brothers style. 1 Answer
Collider2D OnTriggerEnter2D not working, IsTrigger=true and Collider2D IsTrigger=false 0 Answers