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")
 
(2 intermediate revisions by the same user not shown)
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 16: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.