Pickups

How do i make pickups? :roll:

Mario talking to Sonic in a video game comic.

//PickUpEr.js

var pickupRange = 0.00;
var health : SomePlayerHealthType;
var ammo1 : SomeAmmoClipType;
var ammo2 : SomeOtherAmmoClipType;

function Pickup(type : int, value : float)
{
    if(type == 1)
    {
        health.Regenerate(value);
    }
    else if(type == 2)
    {
        ammo1.clips += parseInt(value);
    }
    else if(type == 3)
    {
        ammo2.count += parseInt(value);
    }
}
//PickUp.js

var type = 1;
var value = 0.00;

private var target : Transform;

function Start ()
{
    target = FindObjectOfType(PickUpEr);
}

function Update ()
{
    if( (transform.position - target.transform.position).magnitude < target.pickupRange)
    {
        target.Pickup(type, value);
        Destroy(gameObject);
    }
}

It is different for every game or circumstance.

this might be better:

switch (type) {
   case 1 :
      health.Regenerate(value); 
   break;
   case 2:
      ammo1.clips += parseInt(value); 
   break;
   case 3:
      ammo2.count += parseInt(value);
   break;
   default:
      //do some default action here...
   break;
}

Might a bit faster, especially when you have lots of different pickups

Cheers.

Hey… Was this a “gimmie” post? :sweat_smile:

i edited one of the scripts but i’m still getting c*** about exspressing and unity engine on line 18. :x

//PickUp.js 

var type = 1; 
var value = 0.00; 

private var target : Transform; 

function Start () 
{ 
    target = FindObjectOfType(PickUpEr); 
} 

function Update () 
{ 
    if( (transform.position - target.transform.position).magnitude < target.pickupRange) 
    { 
        target.gameObject(type, value); 
        Destroy(gameObject); 
    } 
}

Ahem* Was that a pickup truck model you where after?
heh

Hey check the bundled fps tutorial, theres a pickup script there, the health packs are using it in the scene…

People here are ridiculously helpful BTW, so just contain your frustration as best as poss, and try and ask in as simple terms as poss (as a general rule).

I know exactly what you are going through-Unity CAN and does deliver, its just that making a game was never a completely drag and drop event.

Its really frustrating when you know its possible, but you dont know how.
I’m still learning to use the docs myself. What seems to work best is if you thoughroughly read the docs and tuts, and then post what you are working from…then others have a starting point when helping you.

the penny will drop…one day it will be you providing the answers, It might be when Yoggy’s grown up and Instantiated little Yoggy’s of his own, but YOU WILL GET THERE…

Keep asking. But do all the tutorials as soon as you can.

AC

were’d you get your pic. from?

Modelled it myself. I’ve got a texturing/audio/rigging/binding demo uploaded to my gmail acc. If anyone wants to see it, PM me your email address, and I’ll send it on :slight_smile:
AC

A,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z. there now figure it out. :smile:

You ever wish you had the powers of The One (A.K.A. Neo) ?

Like Bullet Time?

Bullet time is quite doable:

function Update () {
	if(Input.GetButtonDown("Fire2"))
	Time.timeScale = 0.1;
	if(Input.GetButtonUp("Fire2"))
	Time.timeScale = 1.0;
}

That will kick in slo motion when you hold down your r mouse button
:stuck_out_tongue:
fun and gameshuh?
AC

This is the most random thread ever… :shock:

Your not kidding. I can’t tell if I am just getting slower with age or if there is actually a theme of some sort here. Reminds me of Faulkner’s “As I Lay Dying”.

targos what was with the pickup truck thing?

:smile: :slight_smile: :frowning: :o :shock: :? 8) :lol: :x :stuck_out_tongue: :sweat_smile: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow:

i draw quite a crowd. Huh?

Are you a bot or just really, really bored?

I’m Samus! The heroine of the Metroid series.

How old are you?

:shock:

I like the way you express yourself, quite random funny. Hey! what is that comming? oh no!.. i think it’s the feeling of me becoming a fan…

sight

a fan of a bot… !!!

.ORG