Search Unity

Healthpack Pickup

Discussion in 'Scripting' started by Velketor, Mar 30, 2008.

  1. Velketor

    Velketor

    Joined:
    Sep 15, 2007
    Posts:
    110
    Hello,

    I modified the "Pickup.js" script from the FPS tutorial and applied it to a game object within my scene.

    I'd like for the GUIText to increase by +1 each time the player collides with the game object. Here is the code I currently have applied to my game object:

    Code (csharp):
    1.  
    2. var pickupType = PickupType.Health;
    3. var amount = 1;
    4. var bulletGUI : GUIText;
    5.  
    6. function ApplyPickup (player : FPSWalker) {
    7.     if (pickupType == PickupType.Health) {
    8.     bulletGUI.text += amount;
    9.     }
    10.   }
    11. }
    12.  
    Is something wrong with my coding? I'm not a scripter unfortunately. Please let me know if you have any information/fixes for this! Thank you!

    --Velk
     
  2. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Sorry that was bad code.(removed)

    Is there any reason why you cant use the Pickup script as is?
    AC
     
  3. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    Not sure if it'll make a difference as i'm no scripter myself, but don't u have one too many } at the end of the script?

    Maby try remove it and see if it works?
    Adam.