Comments (3)
Even if you instantiate the Health assets and assign the references at runtime it's still more modular and decoupled than before. This is because the HealthBar component is depending not on a player or an enemy component, but on a FloatVariable/Reference. This means that the HealthBar component is reusable in any other project as long as you have a FloatVariable to reference. HealthBar has no idea that it's the health of a player, enemy etc.
from unite2017.
@prodigga is correct, you do end up having to make instantiated copies if you intend to reuse any of the scriptable objects you make. This pattern works as a replacement for static classes but not as a means by which to create a game.
While making a "model" or "data structure" for data you need to model DOES allow modularity, it is not significantly different than the model/view separation in MVC
from unite2017.
Player Health as a variable is not always the best solution for all game types. For multiplayer, it can be used for a handle to local player's health for use in UI. If you have local multiplayer with a reasonably finite max players (like 4) it could still be useful to have it in a variable, with each player pointing to a different one and each health bar doing the same.
In the case of enemies, that just isn't a place where I would use this since there often is not a centralized feedback system for a single active enemy. There are cases where it makes sense to use on enemies, though. We just shipped a one-on-one vr fighting game where the enemy health was in a variable. You can also picture certain game types that have special HP meters for a boss.
Games often have plenty of candidates for a variable of this sort of global nature. Time spent in a level, quality settings options, analytics data, difficulty setting, etc. HP works out for some games and not for others.
What it comes down to is that this is another tool at your disposal to solve problems. It is still up to the user to be smart about how and when to use it.
from unite2017.
Related Issues (11)
- Add a license HOT 2
- #ifdef UNITY_EDITOR on serialized property HOT 1
- Setter for Value property in FloatReference HOT 3
- FloatReferenceDrawer no longer works HOT 4
- Inventory Demo HOT 3
- Persistence (saving data) HOT 1
- Wouldn't source control be spammed with unnecessary changes caused by persistant scriptable assets being modified at run time? HOT 1
- ScriptableObjectsEvents on build, Android not working. HOT 4
- Type mismatch in Demo05_Sets HOT 4
- Event send an arg HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unite2017.