Search Unity

Moving objects a, b, and c when clicking on object d

Discussion in 'Scripting' started by DaveyJJ, Aug 11, 2005.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    I need a help making this script (in object named "objectd") to move objecta, objectb, and objectc with a 1 second wait between each move. Something like ...

    Code (csharp):
    1.  
    2. function Update () {
    3.     /* move object wait 1 second then move it away and move another object and so on */
    4.         on Input.GetAxis ("Fire"); 
    5.         transform.positionobjecta (0, 0, 10);
    6.         wait 1 second;
    7.  
    8.         transform.positionobjecta (0, 0, 10000);
    9.         transform.positionobjectb (0, 0, 10);
    10.         wait 1 second;
    11.  
    12.         transform.positionobjectb (0, 0, 10000);
    13.         transform.positionobjectc (0, 0, 10);
    14.         wait 1 second;
    15.  
    16.         transform.positionobjecta (0, 0, 10000);
    17. }
    18.  
    Help appreciated. Once I have this down once I'll be fine.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    See attachment.
     

    Attached Files:

  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    As usual, many thanks. That's now stored in my memory for future uses too.
     
  4. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Pardon my ignorance Joe (and other peope who can code) but I'm messing up somewhere ... I now have this code in one of three buttons on my screen -- a GUIText object called "btninstructions" which is used to bring the player to an instruction screen. But if I hit either of the other GUIText buttons on the screen (the btnplay or btncredits objects) the transform happens.

    How do I just get it to work on an individual item so that each of the three buttons on the screen (credits, play and instructions) does a different thing yet works with the same click action (you use the Fire1 button on any of the three objects ... but it does different things). I will make slightly different version of each of these for each button I guess.

    Code (csharp):
    1.  
    2. var btninstructions : Transform;
    3. var btnplay : Transform;
    4. var btncredits : Transform;
    5. var scnsplash : Transform;
    6. var scninstructions : Transform;
    7.  
    8. function Start ()
    9. {
    10.     while (true)
    11.     {
    12.         if (Input.GetButton ("Fire1"))
    13.         {  
    14.             scnsplash.position = Vector3 (-1.058044,11.06043,-16.28964);  
    15.             break;
    16.         }
    17.         yield;
    18.     }  
    19.    
    20.     yield WaitForSeconds (0);
    21.     /* move stuff out of the way and replace with instructions stuff */
    22.     scnsplash.position = Vector3 (0,0,10000);
    23.         btnplay.position = Vector3 (0,0,10000);
    24.         btninstructions.position = Vector3 (0,0,10000);
    25.         btncredits.position = Vector3 (0,0,10000);
    26.  
    27.     /* move new stuff into frame */
    28.         scninstructions.position = Vector3 (-0.8,10.33,-17.13);
    29.         btnplay.position = Vector3 (0.49,0.18,-0.8460407);
    30. }
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You might look at the car_tutorial project which i sent you, in the last chapter.
     
  6. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    D'oh!
     
  7. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    When will this Car tutorial be finished so I can see the solution? 8)