S2ENGINE HD
1.4.6
Official manual about S2Engine HD editor and programming
|
Items are the components of player inventory. They have two representations: ItemObjects and itemTAGs
ItemTAG is the item representation before player takes it. It is what you must add into the scene for letting player take it. ItemTAG has a reference to the ItemObject prefab that must be set into the ItemObject
parameter.
When the player takes the item ( i.e. it sends the ACTION message to the aimed itemTAG), itemTAG replies to player with a message TAKE specifing the ItemObject prefab filename, the item description (item caption) and the unlimited use flag.
ItemObject executes what the item is built for. For example health itemObject sends an "IncreraseHealth" message to the playerCharacter, and then destroy itself.
It is spawned just when user selects the item icon into the inventory and presses the use button. ItemObject must not be inserted into the scene, it is stored as prefab and referenced by the related itemTAG.
Below is an example of an itemTAG prefab related to the light battery
Below is the corresponding itemObject for the light battery.
For adding a new Item you need:
model:
it is the model representing the item in the sceneitemObject:
the reference to the itemObject prefabDestroyWhenTaken:
True if you want the itemObject must disappear when player takes ititemCaption:
the description of the item, either when player aims it and when player select it into the inventoryUseWhenTaken:
True if you want player to use the item just when taking it (no need to put it into the inventory)UnlimitedUse:
True if you want item count to be infinite (i.e. item can be used as many times as you want from the inventory)model:
also itemObject could have a model (but usually it is not required)fsm:
the GameMachine FSM itemObject must execute when instancedicon:
the icon that represents the item into the inventoryiconLit:
the icon when the item is selected into the inventorymaxCount:
the maximum number of items of this type inventory can containlocked:
True if you want the item be unusable until player receives the UNLOCK_ITEM message (see Player Receiving Messages).TagPrefab:
it is the prefab of the related itemTAG, it is needed if you want player can drop items from inventory (see Drop items/weapons).Usually item logic is made using GameMachine (see GameMachine). Usually the itemObject do some work just when created and then it destroy itself.
The following is an example related to the battery Item in the demo project:
As you can see it is a very simple FSM, composed by a single state: