Tutorial - Entity storage – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "Category: Tutorial" to "Category: Ylands Tutorial")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Entity Storage''' is basically a script that can be attached (both in the Editor and via script during runtime) attached to one or more entities.  
'''Entity Storage''' is basically a script that can be attached (via script during runtime) attached to one or more entities.  


This comes in very handy especially when you have entities that have the same behavior and set of variables. Even more so when you’re spawning entities from your script.
This comes in very handy especially when you have entities that have the same behavior and set of variables. Even more so when you’re spawning entities from your script.
Line 10: Line 10:
* We spawn the target dummies from within the Event Listener script. The first one is spawned as the game starts, the next one whenever the Listner detects the current dummy getting “killed”.
* We spawn the target dummies from within the Event Listener script. The first one is spawned as the game starts, the next one whenever the Listner detects the current dummy getting “killed”.


* The dummies are spawned at randomly selected Reference Points in the scene and they have Entity Storage attached. This Entity Storage contains variables - namely how many HP the dummy has. Every time a dummy is spawned this value is randomly set within a given range - so every dummy needs to receive a different amount of damage before it is destroyed.
* The dummies are spawned at randomly selected Reference Points in the scene and they have Entity Storage attached. This Entity Storage contains variables - namely how many points of damage it takes to kill this entity. Every time a dummy is spawned this value is randomly set within a given range - so every dummy needs to receive a different amount of damage before it is destroyed.


* Even though in this example we only have one active target dummy at a time, nothing is stopping you from having many object with attached Entity Storages at the same time.
* Even though in this example we only have one active target dummy at a time, nothing is stopping you from having many object with attached Entity Storages at the same time.
Line 19: Line 19:


----
----
{{Ylands editor navbox}}
{{Navbox/Ylands}}
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}}
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}}


[[Category: Tutorial]]
[[Category: Ylands Tutorial]]

Latest revision as of 17:44, 16 November 2022

Entity Storage is basically a script that can be attached (via script during runtime) attached to one or more entities.

This comes in very handy especially when you have entities that have the same behavior and set of variables. Even more so when you’re spawning entities from your script.


The Targets

  • This is a nice example of how you can use Entity Storage. We want to randomly create target dummies which player can destroy by shooting at them.
  • We spawn the target dummies from within the Event Listener script. The first one is spawned as the game starts, the next one whenever the Listner detects the current dummy getting “killed”.
  • The dummies are spawned at randomly selected Reference Points in the scene and they have Entity Storage attached. This Entity Storage contains variables - namely how many points of damage it takes to kill this entity. Every time a dummy is spawned this value is randomly set within a given range - so every dummy needs to receive a different amount of damage before it is destroyed.
  • Even though in this example we only have one active target dummy at a time, nothing is stopping you from having many object with attached Entity Storages at the same time.
  • Also note that the Event Listener detects only target dummies getting killed - that is because it is set to detected only objects with a certain label - the one we’re attaching to each target dummy as we spawn it.