Object pickup
by Kasey McIntosh · in Technical Issues · 09/13/2007 (11:15 pm) · 2 replies
O.K. I here's what i want to do, Essentially I want to put several different objects in my mission area, and once they are all collected, I would like for the character to get a key. Any Ideas on how that might be done?
Here's what I've tried
" All follow the tutorial that came with the engine"
1. Create seperate items for each, and put them in one SimGroup --- Didn't work.
2. Didi the same thing, but initalized variables for each item, and added them up --- Didn't work.
ITS DRIVING ME CRAZY
Here's what I've tried
" All follow the tutorial that came with the engine"
1. Create seperate items for each, and put them in one SimGroup --- Didn't work.
2. Didi the same thing, but initalized variables for each item, and added them up --- Didn't work.
ITS DRIVING ME CRAZY
About the author
#2
Player.cs onCollision event:
if (collision.type $= "PickupItem")
{
%player.itemsPickedUp += 1;
if (%player.itemsPickedUp = 10)
Key.setTransform(%player.getTransform());
}
or
Player.cs onCollision event:
if (collision.type $= "PickupItem")
{
%player.itemsPickedUp += 1;
if (%player.itemsPickedUp = 10)
%player.pickup(Key);
}
10/13/2007 (5:17 am)
Yeah, that would work, exept make it something likePlayer.cs onCollision event:
if (collision.type $= "PickupItem")
{
%player.itemsPickedUp += 1;
if (%player.itemsPickedUp = 10)
Key.setTransform(%player.getTransform());
}
or
Player.cs onCollision event:
if (collision.type $= "PickupItem")
{
%player.itemsPickedUp += 1;
if (%player.itemsPickedUp = 10)
%player.pickup(Key);
}
Torque Owner Martin Schultz
Pseudo code:
Create the items:
...
new StaticShape(YourSuperItem1)
{
type = "PickupItem";
... bla bla
};
new StaticShape(YourSuperItem2)
{
type = "PickupItem";
... bla bla
};
Player initialization (server/script/game.cs)
%player.myItemList = new SimSet();
Player.cs onCollision event:
if (collision.type $= "PickupItem")
{
%player.myItemList.add(%collisionObject);
}
Ah, well, something like this... :-)