Skip to content

Commit 1696236

Browse files
authored
Merge pull request #14 from Nicole-Scalera/patch-1
Update 12-type-object.md
2 parents b12fb35 + ffe0722 commit 1696236

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_text/12-type-object.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The Type Objects should share the same interface (or parent) to make it easier f
88

99
**When is it useful?**
1010

11-
- When you can't (or don't want to) use class inehritance. Let's say you make a game with animals. You have a base class which is parent to all animals, and then as children to that class you add birds, fish, and mammals. In the bird class you define a flying behavior, which is all fine until you add an ostrich, which can't fly. In that case you have to inherit from the bird class and create new children that can fly and can't fly. But what about bats, which is a mammal that can fly? You don't want to add flying behavior in two separate classes! A better way is to define a flying and a non-flying type in a separate class, so both ostriches remain on the ground and bats can fly.
11+
- When you can't (or don't want to) use class inheritance. Let's say you make a game with animals. You have a base class which is parent to all animals, and then as children to that class you add birds, fish, and mammals. In the bird class you define a flying behavior, which is all fine until you add an ostrich, which can't fly. In that case you have to inherit from the bird class and create new children that can fly and can't fly. But what about bats, which is a mammal that can fly? You don't want to add flying behavior in two separate classes! A better way is to define a flying and a non-flying type in a separate class, so both ostriches remain on the ground and bats can fly.
1212

1313
- In game event systems, the Type Object can be used to define event types as objects. This allows for dynamic registration and handling of different event types during runtime, making the event system more versatile and adaptable.
1414

@@ -25,4 +25,4 @@ The Type Objects should share the same interface (or parent) to make it easier f
2525
- **Component.** The difference is that the Component is not always coupled with something else on the game object – it’s living its own life. In Unity you can add colliders, scripts, mesh renderers and they don’t need to know about each other to function. Type Object, however, is about adding a behavior to an existing class, so the type can't live on its own.
2626

2727

28-
## [Back](../)
28+
## [Back](../)

0 commit comments

Comments
 (0)