Fundaments of Game Design Unity Components Richard Gesick

  • Slides: 6
Download presentation
Fundaments of Game Design Unity Components Richard Gesick

Fundaments of Game Design Unity Components Richard Gesick

Objectives • Unity components • Unity inheritance relationships • Casting and assignments 1 -2

Objectives • Unity components • Unity inheritance relationships • Casting and assignments 1 -2

Unity components • Components are the nuts & bolts of objects and behaviors in

Unity components • Components are the nuts & bolts of objects and behaviors in a game. They are the functional pieces of every Game. Object. • Game. Object is a container for many different Components. By default, all Game. Objects automatically have a Transform Component. • use the Inspector to see which Components are attached to the selected Game. Object. As Components are added and removed, the Inspector will always show you which ones are currently attached. 1 -3

Components (2) • One of the great aspects of Components is flexibility. When you

Components (2) • One of the great aspects of Components is flexibility. When you attach a Component to a Game. Object, there are different values or Properties in the Component that can be adjusted in the editor while building a game, or by scripts when running the game. • Components can include references to any other type of Component, Game. Objects, or Assets 1 -4

Unity components • A child object inherits the transform of the parent game object.

Unity components • A child object inherits the transform of the parent game object. As such, its position is now a local coordinate or an offset from the parent, rather than a world coordinate. • When using an empty game object as a “grouping object”, set its transform position to (0, 0, 0). Then the child objects local and world coordinates will be the same. 1 -5

Unity components (2) • Unity treats the components as a bucket of elements. •

Unity components (2) • Unity treats the components as a bucket of elements. • A game object can be treated as any of its individual components. Thus game objects that have a rigidbody component could be cast as rigidbodies and stored in a collection of rigidbodies. This will be handy when we want to use polymorphism. • A script that is added to a game object is also a component. 1 -6