Easy PickUps System

Overview 

This is a perfect solution if you need to implement some pickups (like med-kits, ammo-packs etc) in your game. Moreover the system allows simulating any pickup holders (like chest for example) and can be used for loot generation from enemies.
System is extremely easy to setup and tune, so jus in couple minutes - you may have pickups/loot/etc in your game.

Some other cool features:

  1. 1)  Cool animator script allows setup simple but cool animations (like rotation or floating) for your

    pickups

  2. 2)  System allows spawning FX (particle prefab / playing sound / etc) once picked up

  3. 3)  Pickup can be collected automatically (for example if player close enough) or even move to gatherer

  4. 4)  Pickup can send to your object (that gathers it) to act accordingly

  5. 5)  There are several useful conditions of emitting (for pickups holders): manually, onDestruction,

    byTimer, onOpenning, onCollision.

Simple demo (example) is provided in the package.

This system works on all platforms supported by Unity3D.

How to use

To use this system – you should just:

1st option (auto):

  1. Drag and drop “pickup” prefab to Hierarchy window. If need - assign any object to it (as a child)

  2. Assign gatherer object to “Target” (this needed only if you want to use AutoCollect)

  3. If you want any FX once picked up – assign gameObject with this effect to “Wreck”

  4. To setup pickup holder (chest for example) – just assign “PickupHolder” component to any object

    and tune it as you want. After this you need to put need pickups (that it should “hold”) to “Pickups” list

2nd option (manual):

  1. Assign “Pickup” component to any object (that has Collider).

  2. If this object doesn’t have rigidbody – set it’s Collider as trigger (check isTrigger box)

  3. If you’d like to have animation for this pickup – assign “SimpleAnimator” component to it, then up-

    date “Movements” list by adding/tune desired movements.

  4. Assign gatherer object to “Target” (this needed only if you want to use AutoCollect)

  5. If you want any FX once picked up – assign gameObject with this effect to “Wreck”

  6. To setup pickup holder (chest for example) – just assign “PickupHolder” component to any object

    and tune it as you want. After this you need to put need pickups (that it should “hold”) to “Pickups” list

To gather pickups manually – call GatherPickup(gatherer: GameObject) function from Pickup component. To emit pickups manually - call EmittPickups () function from PickupHolder component

 

Pickup script description

Main script. Use this script for any pickups (like medkit, ammo etc) creation.
If attached to object - it will seek for target object and move to it. Pickup will be absorbed by target object on collision. Pickup will send sendValue to target's callFunction (use this to increase parameters in it)

Average structure looks like: 

  • Target - Absorber target
  • autoCollect - Find and move to target if it's in activeDistance activeDistance - Radius in which it will see target
  • speed - Movement speed
  • lifeTime - Life time. Infinite if <=0
  • callFunction - Name of target function to apply sendValue sendValue - Value applied to target's callFunction
  • wreck - This object will be created onDestroy 

PickupHolder script description

Use this script to simulate any pickup holders (like chest for example). It also can be used to any other hold- ers and emitters. There are several different conditions for emitting: manually, onDestruction, byTimer, onOpenning, onCollision

Average structure looks like: 

  • emittingCondition - Emitting conditions of predefined types:
  1. manually
  2. OnDestruction
  3. byTimer
  4. OnOpenning
  5. OnCollision
  • justOnePerEvent - Emit only one pickup per event (EmittPickups call)
  • positionShift - Shift initial pickup position to this value
  • timer - Emit after this time (if EmittingType is byTimer)
  • locked - Emitting is prohibited if locked=true (if EmittingType is onOpenning)
  • wreck - Wreck object for pickup holder
  • pickups - Full list of pickups "inside" this pickup holder
  • randomEmittingOrder - If true - will randomize generation order of pickups from the list 

SimpleAnimator script description

Script allows animating (move or rotate) object according to simple list of rules

Average structure looks like: 

cycled - Is whole list of movements cycled (i.e. after las movement in list it starts play the firsr) 
movements - List of all movements, of next structure:

  • direction - Direction of movement, or axis along which it will be rotated (if isRotation = true)
  • isRotation - Is it Rotation or movement
  • speed - Speed of movement/rotation
  • cycleTime - How long will one cycle of movement/rotation (skip action if 0)
  • cycles - How much cycles of this movement/rotation should be (skip action if 0)
  • endTime - Internal variable - your input doesn't influence on it