Tutorial - Entity storage – Ylands
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
'''Entity Storage''' is basically a script that can be attached ( | '''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 | * 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. |
Revision as of 08:05, 9 June 2020
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.