Search Unity

Selecting which items can be picked up

Discussion in 'Physics' started by CoffeeConundrum, Jan 6, 2015.

  1. CoffeeConundrum

    CoffeeConundrum

    Joined:
    Dec 30, 2013
    Posts:
    46
    I've been working on a coin pusher game where you can use the leap motion to drop the coins that you can spawn in. Only issue I've got with this is that I can pick up the coins that are already in play and I was wondering if there was any way to allow the magnetic hand prefab which I'm using to allow me to pick up items to only pick up items that are of a certain tag i.e. the coins which we as the player are using.

    Many thanks!

    Kirsty
     
  2. Barachiel

    Barachiel

    Joined:
    Nov 25, 2012
    Posts:
    147
    What method are you using to pick up the items? I'm afraid the question is a little too vague without an explanation of your current implementation. =)
     
  3. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    Code (csharp):
    1.  
    2. void Start()
    3. {
    4.     //If the tag of the object isnt pickup, disable rigidbody.
    5.     if(gameObject.tag != "Pickup")
    6.     {
    7.         GetComponent<Rigidbody>().enabled = false;
    8.     }
    9. }
    10.  
    But you should really look into the code of picking up objects, and see when things happen.
     
unityunity