Blockland Forums > Modification Help

Spawning a fake dropped item

Pages: << < (2/2)

Wheatley:


--- Quote from: Greek2me on August 04, 2011, 12:59:29 PM ---You can spawn an item like so:

--- Code: (A project of mine) --- %item = new Item()
{
dataBlock = "slyrCTF_Flag" @ %image.colorID @ "Item";

position = %this.getEyeTransform();

spawnBrick = %brick;
canPickup = 1;
};
missionCleanup.add(%item);
--- End code ---

--- End quote ---
Wouldn't that spawn an item on a brick, not physically "drop" it?

Greek2me:

It would spawn an item wherever position is. So in my function, %this is a player, and it spawns the item at the player's eye node. The spawnBrick part is specific to my mod. To make the item actually be thrown, you'd have to add velocity to it in the direction the player is facing.

Wheatley:

I'll try it out. Thanks.

Also, I would use Initial Velocity for the velocity, right?

I'm guessing this works in the same way spawning a projectile from a player would.


Greek2me:


--- Quote from: Wheatley on August 04, 2011, 09:07:28 PM ---Also, I would use Initial Velocity for the velocity, right?

I'm guessing this works in the same way spawning a projectile from a player would.

--- End quote ---
I've never used initialVelocity before, but it would probably work. I used %item.setVelocity("x y z"); after I'd created the item.

And yes, it works in about the same way.

Pages: << < (2/2)

Go to full version