Item Component: Difference between revisions

From Pummel Party Mod Documentation
Jump to navigation Jump to search
(Added images, added usage section with examples and recommended workflow)
 
(5 intermediate revisions by 2 users not shown)
Line 9: Line 9:
=== Carried Items ===
=== Carried Items ===
Used for items that you can hold and use to perform some actions.
Used for items that you can hold and use to perform some actions.
The default held slot is ''Right Hand''. The default held animation is ''One Handed Carry''.
=== Weapon Items ===
=== Weapon Items ===
Used for items that can attack through firing or swinging when used.
Used for items that can attack through firing or swinging when used.
The default held slot is ''Right Hand''. The default held animation is ''Two Handed Carry'' for guns and ''One Handed Carry'' for melee weapons.
=== Worn Items ===
=== Worn Items ===
Used for items that are purely visual, or that provide a buff via actions while held. These cannot be "used" by the player.
Used for items that are purely visual, or provide a buff via actions while held. These cannot be "used" by the player.
=== Pickup Items ===
=== Pickup Items ===
Used for items that can be collected but not held. Once the item is collected by a player it will disappear. Useful for collectables such as coins that reward points or single use health packs that heal the player.
Used for items that can be collected but not held. Once the item is collected by a player it will disappear. Useful for collectables such as coins that reward points or single-use health packs that heal the player.
 
== Player Interaction ==
=== Picking up items ===
The player can pick up an item by walking over it. They will hold the item in the slot defined by the item component (excluding ''Pickup'' items).
 
The player can hold a total of five items at once, one in each slot. The available slots are Right Hand, Left Hand, Head, Back and Body. Trying to pick up an item while already holding one will drop the held item unless it has a higher priority (See [[Item Component#Pickup Settings|pickup settings]]).
 
You can additionally use a [[Give Minigame Item Action]] to give a player an item, and a [[Drop Minigame Item Action]] to force a player to drop an item.
 
=== Dropping items ===
The player can drop any held items with their drop item key (E by default). If holding multiple items this will drop them in first-in-last-out order; the item most recently picked up will be dropped first. The player's ability to drop items manually can be disabled on a per-item basis using the [[Item Component#Drop Settings|drop settings]].
 
Items can be made to drop automatically after some time, or drop after some number of uses (see [[Item Component#Usage Settings|usage settings]]).
 
You can use a [[Drop Minigame Item Action]] to force a player to drop an item.


== Component Settings ==
== Component Settings ==
Line 26: Line 45:
|'''Item Type''' || The type of the item. Can be either Carried, Weapon, Worn or Pickup.
|'''Item Type''' || The type of the item. Can be either Carried, Weapon, Worn or Pickup.
|-
|-
| '''Item Slot''' || Which slot on the player should this item occupy.
| '''Item Slot''' || Which slot on the player this item occupies.
|-
|-
| '''Item Hold Animation''' || The animation to play while this item is being held. ''(Carried and Weapon items only)''
| '''Item Hold Animation''' || The animation to play while this item is being held. ''(Carried and Weapon items only)''
|-
|-
| '''Item Prefab''' || The prefab representing the item's visuals when dropped on the ground and held by the player.
| '''Item Prefab''' || The prefab to represent the item's visuals when dropped on the ground and held by the player.
|-
|-
| '''Unique Drop Prefab''' || Should a different prefab be used when the item is dropped on the ground, than that of the prefab used when held by the player. If used, the ''Item Prefab'' will be used when the item is held, and ''Dropped Item Prefab'' is used when the item is dropped.
| '''Unique Drop Prefab''' || Should a different prefab be used when the item is dropped on the ground, than that of the prefab used when held by the player. If used, the ''Item Prefab'' will be used when the item is held, and ''Dropped Item Prefab'' is used when the item is dropped.
|-
|-
| style="padding-left: 2em;" |  '''Dropped Item Prefab''' || The prefab representing the item's visuals when dropped on the ground.
| style="padding-left: 2em;" |  '''Dropped Item Prefab''' || The prefab to represent the item's visuals when dropped on the ground.
|-
|-
| '''Item Beacon Color''' || Choose between using the default color or a custom color for the item's beacon and glow effects.
| '''Item Beacon Color''' || Choose between using the default color or a custom color for the item's beacon and glow effects.
Line 46: Line 65:
These settings only apply to Weapon-type items.
These settings only apply to Weapon-type items.


You can set the ''Weapon Type'' to either Melee or Gun. Melee allows the weapon to deal short range damage to any players within an area in front of the player. Gun weapons can fire ranged hitscan projectiles to damage other players.
You can set the ''Weapon Type'' to either Melee or Gun. Melee allows the weapon to deal short-range damage to any player within an area in front of the player. Gun weapons can fire ranged hitscan projectiles to damage other players.
====Melee====
====Melee====
{| class="wikitable"
{| class="wikitable"
Line 54: Line 73:
|'''Damage''' || Number of health points to remove from any hit players, per swing.
|'''Damage''' || Number of health points to remove from any hit players, per swing.
|-
|-
| '''Stun on Hit''' || Should hitting a player with this weapon stun them.
| '''Stun on Hit''' || Whether hitting a player with this weapon will stun them.
|-
|-
| style="padding-left: 2em;" | '''Stun Duration (s)''' || How long the stun should last for, in seconds.
| style="padding-left: 2em;" | '''Stun Duration (s)''' || How long the stun should last for, in seconds.
|-
|-
| '''Swing Range''' || How far from the front of the player should the weapon's swing reach.
| '''Swing Range''' || How far from the front of the player the weapon's swing reaches.
|-
|-
| '''Attack Animation''' || The animation of the player when attacking. Note: this doesn't affect the range or hit area of the item, just the animation you and other players will see.
| '''Attack Animation''' || The animation of the player when attacking. Note: this doesn't affect the range or hit area of the item, just the animation you and other players will see.
Line 72: Line 91:
| style="padding-left: 2em;" | ''Hit Scan'' || The weapon fires discrete hitscan projectiles.
| style="padding-left: 2em;" | ''Hit Scan'' || The weapon fires discrete hitscan projectiles.
|-
|-
| style="padding-left: 4em;" | '''Damage''' || Number of health points to remove from any hit players, per bullet.
| style="padding-left: 4em;" | '''Spawn Bullet Effect''' || Show a tracer effect to visualise the bullets.
|-
|-
| style="padding-left: 4em;" | '''Stun on Hit''' || Should hitting a player with this weapon stun them.
| style="padding-left: 6em;" | '''Bullet Color''' || The color of the bullet tracer.
|-
|-
| style="padding-left: 6em;" | '''Stun Duration (s)''' || How long the stun should last for, in seconds.
| style="padding-left: 2em;" | ''Beam'' || The weapon fires a continuous hitscan beam. Shares most properties with ''Hit Scan'' weapons.
|-
|-
| style="padding-left: 4em;" | '''Shot Count''' || Number of bullets shot each time the weapon is fired.
| style="padding-left: 4em;" | '''Beam Damage Cooldown''' || Time between each tick of damage being applied to the target.
|-
|-
| style="padding-left: 4em;" | '''Spread''' || Number of bullets shot each time the weapon is fired. Can set the min and max horizontal and vertical spread, in degrees.
| style="padding-left: 4em;" |'''Beam Sound''' || The audio clip to play whenever the beam weapon is actively firing. It plays on repeat. Can choose from None, Laser, and Custom.
|-
|-
| style="padding-left: 6em;" | ''None'' || All bullets come out exactly where the player aimed.
| '''Damage''' || Number of health points to remove from any hit players, per bullet.
|-
|-
| style="padding-left: 6em;" | ''Random'' || Bullets come out where the player aimed, plus some random aim offset.
| '''Stun on Hit''' || Whether hitting a player with this weapon will stun them.
|-
|-
| style="padding-left: 4em;" | '''Max Distance''' || Maximum distance the bullets can travel in units.
| style="padding-left: 2em;" | '''Stun Duration (s)''' || How long the stun should last for, in seconds.
|-
|-
| style="padding-left: 4em;" | '''Spawn Bullet Effect''' || Should a tracer effect be played to vizualise the bullets.
| '''Shot Count''' || Number of bullets shot each time the weapon is fired.
|-
|-
| style="padding-left: 6em;" | '''Bullet Color''' || The color of the bullet tracer.
| '''Spread''' || Number of bullets shot each time the weapon is fired. Can set the min and max horizontal and vertical spread, in degrees.
|-
|-
| style="padding-left: 4em;" | '''Spawn Trail Effect''' || Should a longer lasting secondary tracer effect be used.
| style="padding-left: 2em;" | ''None'' || All bullets come out exactly where the player aimed.
|-
|-
| style="padding-left: 6em;" | '''Start Color''' || Color of the secondary tracer at the end closest to the origin of the shot.
| style="padding-left: 2em;" | ''Random'' || Bullets come out where the player aimed, plus some random aim offset.
|-
|-
| style="padding-left: 6em;" | '''End Color''' || Color of the secondary tracer at the end furthest from the origin of the shot.
| '''Max Distance''' || Maximum distance the bullets can travel in units.
|-
| style="padding-left: 6em;" | '''Trail Width''' || The width of the secondary tracer effect.
|-
| style="padding-left: 6em;" | '''Trail Length''' || The length of the secondary tracer effect before it fades out, from the origin of the shot.
|-
| style="padding-left: 2em;" | ''Beam'' || The weapon fires a continuous hitscan beam. Shares most properties with ''Hit Scan'' weapons.
|-
| style="padding-left: 4em;" | '''Beam Damage Cooldown''' || Time between each tick of damage being applied to the target.
|-
|-
| style="padding-left: 2em;" | ''Area'' || The weapon deals damage to all objects within an area.
| '''Spawn Trail Effect''' || Should a longer-lasting secondary tracer effect be used.
|-
|-
| style="padding-left: 4em;" | '''Shape''' || The shape to deal damage within.
| style="padding-left: 2em;" | '''Start Color''' || Color of the secondary tracer at the end closest to the origin of the shot.
|-
|-
| style="padding-left: 6em;" | ''Point'' || Deal damage to anything that overlaps a point.
| style="padding-left: 2em;" | '''End Color''' || Color of the secondary tracer at the end furthest from the origin of the shot.
|-
|-
| style="padding-left: 6em;" | ''Sphere'' || Deal damage to anything that overlaps a point.
| style="padding-left: 2em;" | '''Trail Width''' || The width of the secondary tracer effect.
|-
|-
| style="padding-left: 8em;" | '''Radius''' || Radius of the damage sphere.
| style="padding-left: 2em;" | '''Trail Length''' || The length of the secondary tracer effect before it fades out, from the origin of the shot.
|-
|-
|'''Fire Sound''' || The audio clip that plays whenever the weapon fires. Can choose from None, Rifle, Shotgun, Sniper and Custom which allows any audio clip to be used.
|'''Fire Sound''' || The audio clip to play whenever the weapon fires. Can choose from None, Rifle, Shotgun, Sniper and Custom which allows any audio clip to be used.
|}
|}
<br clear="all">
<br clear="all">
Line 142: Line 153:
! Property !! Description
! Property !! Description
|-
|-
|'''Held Position Offset''' || An offset to apply to the position of the item when it is held. If the item is a strange shape or should be held differently given the ''Item Slot'' and ''Item Hold Animation'', you can adjust it's positioning here.
|'''Held Position Offset''' || An offset to apply to the position of the item when it is held. If the item is a strange shape or should be held differently given the ''Item Slot'' and ''Item Hold Animation'', you can adjust its positioning here.
|-
|-
| '''Held Rotation Offset''' || An Euler x, y, z rotation to apply to the item when held.
| '''Held Rotation Offset''' || An Euler x, y, z rotation to apply to the item when held.
Line 159: Line 170:
! Property !! Description
! Property !! Description
|-
|-
|'''Cooldown''' || The number of seconds that must pass between each use of the item.
|'''Cooldown''' || The minimum number of seconds that must pass between each use of the item.
|-
|-
| '''Has Limited Uses''' || Should this item be dropped after a set number of uses. If false, this item can be used infinitely.
| '''Has Limited Uses''' || Should this item be dropped after a set number of uses. If false, this item can be used infinitely.
Line 165: Line 176:
| style="padding-left: 2em;" | '''Drop After Uses''' || The number of uses before this item will be automatically dropped by the player.
| style="padding-left: 2em;" | '''Drop After Uses''' || The number of uses before this item will be automatically dropped by the player.
|-
|-
| ''''On Use' Actions''' || A set of action to perform whenever this item is used.
| ''''On Use' Actions''' || A set of actions to perform whenever this item is used.
|}
|}
<br clear="all">
<br clear="all">
Line 190: Line 201:


== Usage ==
== Usage ==
When using items, it can be beneficial to turn them into prefabs. It can be tedious to update copies of items if you have many of them in the scene. Using prefabs, if you want to change the properties of an item you can simply update the item within the prefab, then all instances in the scene will update.
When using items, it can be beneficial to turn them into prefabs. It can be tedious to update copies of items if you have many of them in the scene. Using prefabs, if you want to change the properties of an item you can simply update the item within the prefab, and then all instances in the scene will update.


The recommended workflow for creating an item like this is the following:
The recommended workflow for creating an item like this is the following:
Line 203: Line 214:


=== Usage Examples ===
=== Usage Examples ===
There are many creative uses for the different item types. Try using different actions when the item is picked up, held, used or dropped to create some unique effects.
There are many creative uses for the different item types. Try using different actions when the item is picked up, held, used, or dropped to create some unique effects.


Here are some basic ideas to get you thinking:
Here are some basic ideas to get you thinking:
Line 214: Line 225:
* Melee
* Melee
** Swords
** Swords
** Light sabers
** Lightsabers
** Boxing gloves that can punch players back
** Boxing gloves that can punch players back
* Guns
* Guns
Line 222: Line 233:


Worn
Worn
* Clothing or armor that does nothing but look cool
* Clothing or armour that does nothing but look cool
* A hat that increases movement speed while worn
* A hat that increases movement speed while worn
* A miner's headlamp with a light attached to light up the scene in front of the player
* A miner's headlamp with a light attached to light up the scene in front of the player
Line 229: Line 240:
* Coins that reward points
* Coins that reward points
* Collectable that gives the player an upward boost
* Collectable that gives the player an upward boost
* A goal item that must be collected to win the minigame.
* A goal item that must be collected to win the minigame




[[Category:Gameplay Components]]
[[Category:Gameplay Components]]
[[Category:Components]]
[[Category:Components]]

Latest revision as of 20:20, 26 February 2023

The item component is a gameplay component that creates a collectable item that the player can hold, wear, and use.

Item components cannot be added to gameobjects that have child gameobjects in the hierarchy. While an item component is attached to a gameobject, that gameobject cannot have any child gameobjects added and will be given a unique icon and color in the hierarchy.

Item Types

The four item types and their default beacon colors.

There are four types of items. Each item type is intended for different use cases. The item type affects the attributes available for the item and whether you can hold or use the item.

Carried Items

Used for items that you can hold and use to perform some actions.

The default held slot is Right Hand. The default held animation is One Handed Carry.

Weapon Items

Used for items that can attack through firing or swinging when used.

The default held slot is Right Hand. The default held animation is Two Handed Carry for guns and One Handed Carry for melee weapons.

Worn Items

Used for items that are purely visual, or provide a buff via actions while held. These cannot be "used" by the player.

Pickup Items

Used for items that can be collected but not held. Once the item is collected by a player it will disappear. Useful for collectables such as coins that reward points or single-use health packs that heal the player.

Player Interaction

Picking up items

The player can pick up an item by walking over it. They will hold the item in the slot defined by the item component (excluding Pickup items).

The player can hold a total of five items at once, one in each slot. The available slots are Right Hand, Left Hand, Head, Back and Body. Trying to pick up an item while already holding one will drop the held item unless it has a higher priority (See pickup settings).

You can additionally use a Give Minigame Item Action to give a player an item, and a Drop Minigame Item Action to force a player to drop an item.

Dropping items

The player can drop any held items with their drop item key (E by default). If holding multiple items this will drop them in first-in-last-out order; the item most recently picked up will be dropped first. The player's ability to drop items manually can be disabled on a per-item basis using the drop settings.

Items can be made to drop automatically after some time, or drop after some number of uses (see usage settings).

You can use a Drop Minigame Item Action to force a player to drop an item.

Component Settings

General Settings

The general settings in the inspector. This item is a hat worn on the player's head.

General settings about the item. Not all options are available for all item types.

Property Description
Item Type The type of the item. Can be either Carried, Weapon, Worn or Pickup.
Item Slot Which slot on the player this item occupies.
Item Hold Animation The animation to play while this item is being held. (Carried and Weapon items only)
Item Prefab The prefab to represent the item's visuals when dropped on the ground and held by the player.
Unique Drop Prefab Should a different prefab be used when the item is dropped on the ground, than that of the prefab used when held by the player. If used, the Item Prefab will be used when the item is held, and Dropped Item Prefab is used when the item is dropped.
Dropped Item Prefab The prefab to represent the item's visuals when dropped on the ground.
Item Beacon Color Choose between using the default color or a custom color for the item's beacon and glow effects.
Custom Item Beacon Color The color of the item's beacon and glow effects. The alpha value of the color is not used. If you want to disable the beacon and glow completely, set the color to black.


Weapon Settings

The weapon settings in the inspector. These settings create a shotgun-style weapon.

These settings only apply to Weapon-type items.

You can set the Weapon Type to either Melee or Gun. Melee allows the weapon to deal short-range damage to any player within an area in front of the player. Gun weapons can fire ranged hitscan projectiles to damage other players.

Melee

Property Description
Damage Number of health points to remove from any hit players, per swing.
Stun on Hit Whether hitting a player with this weapon will stun them.
Stun Duration (s) How long the stun should last for, in seconds.
Swing Range How far from the front of the player the weapon's swing reaches.
Attack Animation The animation of the player when attacking. Note: this doesn't affect the range or hit area of the item, just the animation you and other players will see.

Gun

Property Description
Damage Type How damage is dealt by the weapon.
Hit Scan The weapon fires discrete hitscan projectiles.
Spawn Bullet Effect Show a tracer effect to visualise the bullets.
Bullet Color The color of the bullet tracer.
Beam The weapon fires a continuous hitscan beam. Shares most properties with Hit Scan weapons.
Beam Damage Cooldown Time between each tick of damage being applied to the target.
Beam Sound The audio clip to play whenever the beam weapon is actively firing. It plays on repeat. Can choose from None, Laser, and Custom.
Damage Number of health points to remove from any hit players, per bullet.
Stun on Hit Whether hitting a player with this weapon will stun them.
Stun Duration (s) How long the stun should last for, in seconds.
Shot Count Number of bullets shot each time the weapon is fired.
Spread Number of bullets shot each time the weapon is fired. Can set the min and max horizontal and vertical spread, in degrees.
None All bullets come out exactly where the player aimed.
Random Bullets come out where the player aimed, plus some random aim offset.
Max Distance Maximum distance the bullets can travel in units.
Spawn Trail Effect Should a longer-lasting secondary tracer effect be used.
Start Color Color of the secondary tracer at the end closest to the origin of the shot.
End Color Color of the secondary tracer at the end furthest from the origin of the shot.
Trail Width The width of the secondary tracer effect.
Trail Length The length of the secondary tracer effect before it fades out, from the origin of the shot.
Fire Sound The audio clip to play whenever the weapon fires. Can choose from None, Rifle, Shotgun, Sniper and Custom which allows any audio clip to be used.


Pickup Settings

The pickup settings in the inspector.
Property Description
Pickup Sound Type Select the sound to play when picking up this item.
Unique Pickup Makes it so this item will not be picked up if the player is already holding an item in this item's slot.
Item Pickup Priority The priority assigned to picking up this item. If it is greater than that of the item currently held in the same slot, the held item will be dropped and this one will be picked up.
On Pickup' Actions A set of actions to perform whenever this item is picked up.


Held Settings

The held settings in the inspector.
Property Description
Held Position Offset An offset to apply to the position of the item when it is held. If the item is a strange shape or should be held differently given the Item Slot and Item Hold Animation, you can adjust its positioning here.
Held Rotation Offset An Euler x, y, z rotation to apply to the item when held.
'While Held' Action Delay (s) The number of seconds between each firing of the 'While Held' Actions.
'While Held' Actions A set of actions to perform while the item is being held. Fires constantly with a delay of 'While Held' Action Delay (s) between each firing.


Usage Settings

The usage settings in the inspector.

These settings are only available on Carried and Weapon type items. Worn and Pickup items cannot be "used" so these settings do not apply.

Property Description
Cooldown The minimum number of seconds that must pass between each use of the item.
Has Limited Uses Should this item be dropped after a set number of uses. If false, this item can be used infinitely.
Drop After Uses The number of uses before this item will be automatically dropped by the player.
'On Use' Actions A set of actions to perform whenever this item is used.


Drop Settings

Drop settings in the inspector. This item will drop automatically after 20 seconds and cannot be picked up again.
Property Description
Can Be Dropped When false, the player is not able to drop this item using the drop button.
Automatically Drop After Time Should this item be automatically dropped by the player after an amount of time has passed.
Drop After Time (s) Number of seconds that will pass from the time of item pickup before the item is automatically dropped by the player. Will still drop if Can Be Dropped is false.
Disappear When Dropped Should the item destroy itself when it is dropped.
Drop On Death Should the item be dropped by the player when the player dies. If false, the player will respawn holding the item.
'On Drop' Action A set of actions to perform whenever this item is dropped. Will fire if dropped for any reason, not just the player pressing the drop button.


Usage

When using items, it can be beneficial to turn them into prefabs. It can be tedious to update copies of items if you have many of them in the scene. Using prefabs, if you want to change the properties of an item you can simply update the item within the prefab, and then all instances in the scene will update.

The recommended workflow for creating an item like this is the following:

  1. Create a prefab to contain the item's visuals. This does not have an item component, only visual components and objects like props, lights, particle effects, etc.
  2. Create a second prefab. This will contain the item. Open the prefab and on the root gameobject (The one at the top of the hierarchy), add the Item Component.
  3. Populate this item component with the item properties you want. Use the first prefab as the Item Prefab on the Item Component.
  4. Place instances of this second prefab into the scene. Instead of using the item directly in the scene, you place prefab instances of the item.

You'll need to follow this approach if you want to use a Spawner Component to spawn items, or use the item with the Give Minigame Item Action

Do note that there is nothing wrong with using an item component directly in the scene, and it is usually easier if you only need one or very few copies of an item. Do consider using this prefab approach however if you have many copies of the same item.

Usage Examples

There are many creative uses for the different item types. Try using different actions when the item is picked up, held, used, or dropped to create some unique effects.

Here are some basic ideas to get you thinking:

Carried

  • A bomb that explodes after some time, killing the player
  • A hot potato that damages the player while holding it

Weapon

  • Melee
    • Swords
    • Lightsabers
    • Boxing gloves that can punch players back
  • Guns
    • Rifles
    • Shotguns
    • Laser beam guns

Worn

  • Clothing or armour that does nothing but look cool
  • A hat that increases movement speed while worn
  • A miner's headlamp with a light attached to light up the scene in front of the player

Pickups

  • Coins that reward points
  • Collectable that gives the player an upward boost
  • A goal item that must be collected to win the minigame