Search Unity

Noobish request.

Discussion in 'Scripting' started by Xcommand, Sep 4, 2011.

  1. Xcommand

    Xcommand

    Joined:
    Sep 3, 2011
    Posts:
    4
    Silly me. Can anyone help me with small script? :(
    Here is me silly problem: We have an rigid item and a player. When player clicks on item, that item should stuck to players back ( Camera set behind the player ). You can move around and have that item on the back. Then player can click it again and that item unstuck from players and get physic properties "on" again.
    I will appreciated any help. :D
     
  2. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    You need to add a gameobject and place it where you want the item to be on the back. When you press the button, use the Find function to find the object and attach one to the other.
    I'm guessing there is a detach function also, but I'm not sure.
     
  3. Xcommand

    Xcommand

    Joined:
    Sep 3, 2011
    Posts:
    4
    Yeah i already got object on the back called "Backpack" special for that script. Right now i have some issues in moving one object to another and turning physics "off"... i'm such a noob -_-
     
  4. Xcommand

    Xcommand

    Joined:
    Sep 3, 2011
    Posts:
    4
    I don't know how to change hierarchy trough script, and turning "rigid body" off, on a object. Anyone?
     
  5. grooc

    grooc

    Joined:
    May 23, 2011
    Posts:
    15
    GameObject.transform.parent = transform; // this object is now a child of gameobject

    check here
    and here
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yup the silly documentation will help you with the silly questions you have for your silly problem.