Collecting objects (SOLVED)

Ok, so, if a game object has a collision component attached to it and the collision component is configured correctly to collide with one or more other collision groups the physics system will automatically generate contact_point_response and collision_response messages. These messages are sent to any script components attached to the colliding game objects.

You snippet of code looks fine. If nothing is happening then you have not configured the collision components correctly. Some things to check:

  1. Does your player/hero game object have a collision component?
  2. Does your coin game object have a collision component?
  3. Does your hero collision component have a mask value that is matching the coin’s collision component group?
  4. Does your coin collision component have a mask value that is matching the hero’s collision component group?
  5. Have you attached the script with the snippet of code you posted to the coin game object?
  6. How does the game look when running if you enable physics.debug in game.project? Do you see any contact responses?

Other than that, please read and re-read the physics manual and the tutorial.

2 Likes