Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

OnCollisionEnter multiple objects

$
0
0
Hi, first post here. I'm having a problem getting OnCollisionEnter to work with another object. Basically in my game I have coins that fall down from the sky. The player is supposed to collide with the coins and the coins should disappear (basic mario stuff). Now these coins have a rigidBody on them because I want to use gravity to make them fall. The issue I run into is once the Coin has reach the ground it enters collision with the ground and The player cannot pick it up. However if the player reaches the coin before it touches the ground it works properly and disappears. I'm not sure what's going on with OnCollisionEnter and why the player can't just pick up the coin when it's on the ground. Here's my code for the Coin... function Start () { Physics.gravity = Vector3(0,gravityValue,0); } function OnCollisionEnter(other:Collision) { print("COLLiDING"); if(other.gameObject.tag == "Player") { print("touching coin"); Destroy(gameObject); } }

Viewing all articles
Browse latest Browse all 171066

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>