I am trying to create pickups, that appear after an enemy dies, and that the player can pick up, but I am running into some issues.
First of all, I want the pickups to be affected by gravity, so I need a rigidbody2d and a boxcollider2d (non-trigger), so this works.
Now, if I want to collect the pickups on contact, I need to make the layers for the loot and the player get in contact, so that they can interact.
Now, of course, I do not want to push the pickups around. I want to actually pick them up when I touch them, but the collider is not a trigger so I thought I would use OnCollisionEnter to handle this.
void OnCollisionEnter2D(Collision2D other)
{
var loot = other.gameObject.GetComponent<ILoot>();
loot?.PickUp(gameObject); // Destroys also the pickup
}
While this works, I am still using a non-trigger collider, which means that there are some physics effects that are not desired. For instance, when I "jump" onto the pickups.
Notice the subtle, but still present, slowdown in the fall, when the player enters in touch with the pickups?
How could I solve this issue??