i have a function that looks like this:
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.name == "Despawner")
{
Destroy(this.gameObject);
}
if (collision.gameObject.name == "Char")
{
Destroy(this.gameObject);
ScoreHandler.coinsCollected++;
}
}
Basically what i want is if the coin is colliding with the player, i want the coin to be removed, but also remove the physical effects from the collision, so my if i jump to the coin from below, my character won't fall back to the ground, it just goes over it and removes it like if he would have collected it.
I also tried changing OnCollisionEnter2D to OnTriggerEnter2D but didn't get it working.
Edit: I changed to OnTriggerEnter2D from OnCollisionEnter2D. now the character goes through the coins but doesn't pick them up, like if there is no collision at all, also checked the IsTrigger in the Editor for the GameObject.