### Spawing Item Slightly Higher?

There are no stupid questions, just stupid answers.

#### Spawing Item Slightly Higher?

Jason Campbell
Posts: 362
Joined: Fri Feb 13, 2015 2:51 am

Hello all,

I've finally got a loot box that spawns a random item inside it.Problem is it places it at the very bottom of the chest, so it can't be seen.

Any way to spawn it in the center of the transform of the box?

Thanks

%trans is the chests transform
%lootItem = new Item()
{
datablock = %item;
static = true;
rotate = false;
};
%trans=%obj.getTransform();
%lootItem.setTransform(%trans);

#### Re: Spawing Item Slightly Higher?

Jason Campbell
Posts: 362
Joined: Fri Feb 13, 2015 2:51 am

I figure it out. I re-imported the box with the center at where I wanted the item to spawn. Works great now.

#### Re: Spawing Item Slightly Higher?

Duion
Posts: 1626
Joined: Sun Feb 08, 2015 1:51 am

I hardly know any games that actually spawn items inside boxes, in most games you click the box and a GUI opens that shows that there is an item in the box, while there is actually nothing inside it for real. Other games spawn the items outside of the box when you "open" it or it is destroyed.

#### Re: Spawing Item Slightly Higher?

Jason Campbell
Posts: 362
Joined: Fri Feb 13, 2015 2:51 am

I got it working pretty slick now. I have a random item(weapon, health kit, ammo, ect) spawn right before the open lid animation.

I wanted it to occur without a GUI. I have a button press to pickup stuff so this works well.

#### Re: Spawing Item Slightly Higher?

fLUnKnhaXYU
Posts: 172
Joined: Wed Nov 15, 2017 8:19 am
you can use vectorAdd in the case that you might want to add a large item and make it appear above the prize box .

#### Re: Spawing Item Slightly Higher?

Jason Campbell
Posts: 362
Joined: Fri Feb 13, 2015 2:51 am

Nice! Thanks f. That is what I was looking for originally.

#### Re: Spawing Item Slightly Higher?

Duion
Posts: 1626
Joined: Sun Feb 08, 2015 1:51 am

If it appears on top of the box anyways, you can shoot a raycast from the top and it will always spawn exactly on top of the surface, start 1.5m from the top or so in case it is indoors so it will not spawn on the upper floor.

#### Who is online

Users browsing this forum: No registered users and 3 guests