# Lecture_003

## Components

Component of Modern Game: game objects

• dynamic game object: objects with action and animations

• static game object: houses, static model

• environment: terrain, vegetation, sky (could still be interactive)

• other game objects: like trigger

Game objects have properties (variables) and behavior (functions)

Note that UObject is not game object, but a wrapper on C's object.

## Ticking

There are two types of ticking.

1. tick logic
2. tick render

They are usually asynchronous and can be spread to more than two threads.

### Interaction Between Game Objects

Traditionally, we code interaction within game objects to search for related game objects and call game objects functions.

But event-based interactions are easier to code with.

### Scene Management

However, if event is sent to every game objects, then the cost is high.

However, if the grid is crowded, then the cost is still high.

Bounding Volume Hierarchies: merging bounding box of objects.

• when we throw away objects that is outside of our canvas.

• when we calculate collision

You need to choose a scene management method that is suit to your game. For enclosed scene with minimal objects that can move, BSP or Potentially Visible Sets (PVS) would be good. However, BVH has low cost and is more suited for moving scenes.

### The Problem with Ticking

Imagine a situration: in one tick

1. your keyboard input triggers an animation of a character
2. the character triggers physics
3. the physics will again affect the animation

One way physics can interact with animation is that we blend physical impact (slam face) with animated impact so that the interaction looks natural.

In above example, the animation will change multiple time in one tick.

The order of ticks matters! Imagine a situration: using event system, in the same tick, a character is shot by a bullet and the character is healed by his teammate. Since those two events were sent in the same tick, it is ambiguous whether after the tick, the character is alive. If we only process event in order of reception time, then deterministic input (sending the command in the same tick) can result nondeterministic result (died or alive).

pre-tick, post-tick is used to solve the order of events.

Recursive dependency will result in game lag within one or two ticks.

Things to keep in mind in design:

• you send event based on the same tick as current tick or the previous tick

• do you wait for one tick to react when an object received an event or do it in the same tick

When a tick takes too long to compute:

1. only tick essential stuff first that can affect screen largely (such as movement)
2. tick 2 ticks at once without user input (dangerous)
3. optimize your code to interleave calculations from a tick to other ticks (like massive explosion)

Logic will run 1 tick ahead. Swaping frame buffer delays the display another tick... So we need to optimize how many ticks has passed from input to screen outcome. There are many tricks to put into minimize tick delay to optimize hitfeel.

Table of Content