I created a dynamic coin. This coin moves like a normal object, hits the ground and is affected by gravity. When I collect this coin with my player object, I can destroy it, but just before it is destroyed, if the coin has a speed, a force affects the player. (Like getting a punch from where the coin came from). I can't make the coin isTrigger because it needs to interact normally with other objects. I can't make the player kinematic because it needs to interact normally with other objects. When I do "Physics.IgnoreCollision(playerCollider, coinCollider);", I can't collect the coins. OnCollisionEnter doesn't work because I don't want a collision and the coin to physically apply force to the player. OnTriggerEnter doesn't work either because isTrigger is closed. Please, how can I solve it?
OnTriggerEnter&Stay OnCollisionEnter&Stay
I created a dynamic coin. This coin moves like a normal object, hits the ground and is affected by gravity. When I collect this coin with my player object, I can destroy it, but just before it is destroyed, if the coin has a speed, a force affects the player. (Like getting a punch from where the coin came from). I can't make the coin isTrigger because it needs to interact normally with other objects. I can't make the player kinematic because it needs to interact normally with other objects. When I do "Physics.IgnoreCollision(playerCollider, coinCollider);", I can't collect the coins. OnCollisionEnter doesn't work because I don't want a collision and the coin to physically apply force to the player. OnTriggerEnter doesn't work either because isTrigger is closed. Please, how can I solve it?
OnTriggerEnter&Stay OnCollisionEnter&Stay
I would simply add a child to the player on a different layer - let's call it COINCOLLECTOR
with a simple Trigger collider (sphere for instance). Probably doesn't have to be a mesh collider and you can save some performance that way.
Then configure the layers so that only the player child trigger interacts with coins, not the player itself.
This way
COINS
just keep interacting with basically all you already hadPLAYER
also keeps interacting with the rest of the worldPLAYER
does NOT collide with COINS
so there will be no physics impact caused by the coinsCOINCOLLECTOR
can collect the COINS
using a trigger