admin管理员组文章数量:1313156
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
Share Improve this question edited Jan 31 at 14:42 derHugo 90.9k9 gold badges90 silver badges134 bronze badges asked Jan 30 at 20:59 AbdAbd 11 bronze badge 01 Answer
Reset to default 0I 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 withCOINS
so there will be no physics impact caused by the coins- but
COINCOLLECTOR
can collect theCOINS
using a trigger
本文标签: Unity 3d collectible coins physically apply force to the playerStack Overflow
版权声明:本文标题:Unity 3d collectible coins physically apply force to the player - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741936361a2405878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论