Skip to content

Commit ad82a2d

Browse files
committed
Updated readme
1 parent 294f7e2 commit ad82a2d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

_text/2-flyweight.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 2. Flyweight
22

3-
Even though a single object uses little memory – instantiating many of them can cause trouble, so you need to make the objects lighter by sharing code.
3+
Even though a single object uses little memory – using many of them can cause trouble, so you need to make the objects lighter by sharing code.
44

55
**How to implement?**
66

@@ -10,9 +10,13 @@ Separate the data that’s not specific to a single instance of that object and
1010

1111
- If you make Minecraft and have a million cubes in the scene. All cubes can share the same texture if you put all textures that belongs to each cube type (grass, stone, sand, etc) into a [texture atlas](https://en.wikipedia.org/wiki/Texture_atlas).
1212

13-
- If you make a strategy game, all infantry units share the same mesh, texture, maxHealth settings, etc. You only need to create one object with this data and then all infantry units can share that object. Each individual infantry unit only need to keep track of its own position and health.
13+
- If you make a strategy game, all infantry units share the same mesh, texture, animation, maxHealth settings, etc. You only need to create one object with this data and then all infantry units can share that object. Each individual infantry unit only need to keep track of its own position and health.
1414

15-
- This is implemented in Unity as [sharedMesh](https://docs.unity3d.com/ScriptReference/MeshFilter-sharedMesh.html) and [sharedMaterial](https://docs.unity3d.com/ScriptReference/Renderer-sharedMaterial.html). If you make a change to a sharedMesh then all objects using that mesh will get a new mesh.
15+
- This is implemented in Unity as [sharedMesh](https://docs.unity3d.com/ScriptReference/MeshFilter-sharedMesh.html) and [sharedMaterial](https://docs.unity3d.com/ScriptReference/Renderer-sharedMaterial.html). If you make a change to a sharedMesh then all objects using that mesh will get a new mesh.
16+
17+
- In an open world game you can use the trees and rocks multiple times by rotating and scaling them - and no-one will see they are the same model.
18+
19+
- If you make a car game it is enough to use one crash sound - and then change the settings of that sound, such as pitch, to create different crash sounds every time the car crashes.
1620

1721
**Related patterns**
1822

0 commit comments

Comments
 (0)