Screen recording: http://dennett.cs-i.brandeis.edu/talks/cs65a/L06/Resources/
Today we introduce Logic Bricks and the Sensor/Controller/Actuator model of Game programming. We will show how to create a simple game by linking in objects and creating an avatar that is controlled by keyboard commands. We will spend most of the day exploring the physics of avatars and comparing the game play produced by using different approaches to avatar control (position, velocity, force).
We will also show how to add a soundtrack and sound effects, and how to switch to a different camera in real time.
Topics to be covered:
- keyboard sensors
- always sensors
- general sensor settings
- Motion actuators
- Position, Linear Velocity, Force Vectors
- Orientation, Angular Velocity, Torque Vectors
- Sound actuators
- Scene actuators
Physics Engine architecture overview.
- What kind of information does the Physics engine need to know about each object to complete the simulation?
- position, orientation, linear velocity, angular velocity, force, torque
- How does it calculate the "state of the world" at the next time step from the "state of the world" in the current time step?
- Newton equations for dynamic objects (p' = v, v'=a, a = F/m, if you know the force you can calculate the change in position)
- Newton-Euler equations for rigid bodies allows one to calculate the change in orientation from a knowledge of the torque on each object - details can be found here http://www.cs.cornell.edu/courses/cs6650/2011sp/
- How are collisions handled?
- First we need efficient collision detection (often we use a simple shape to calculate collisions ... give demo)
- A collision results in new forces applied to the bodies involved, calculating these forces requires knowledge of the material's elasticity and friction and the mass and the inertia tensor.
- How often are these physics engine steps calculated?
- The "world pane" in the properties window lets you set the number of physics frames per second (250 fps max) and also the number of simulation steps for each physics step. The actual frame rate (the number of frames drawn on the screen) is independent of the physics frame rate and is typically around 60 frames per second.
Logic Brick model
The logic editor allows you to change the state of the game by specifying how each object in the game responds to events.
What kinds of events does Blender recognize?
- there are two basic kinds of events -
- external events such as key presses or mouse motion
- internal events generated by the game simulations (like collisions or property relationships, timer alerts, message notifications)
- we will focus on three event types today - keyboard, always, and collision
What kinds of actions can be specified in response to those events?
- any aspect of the game can be changed, but we will focus on the motion actuators today
- motion actuators allow you to change the position, orientation, linear velocity, angular velocity, force, or torque
We will now create several simple avatars and examine the game play effects of different types of motion actuators ...
First explore feel of the game ... on a racetrack demo
Explore relationship between triggering frequency in tap mode and physics fps settings.
Question: How long will it take an avatar to go 100 meters with different methods
Question: What if two different operations are specified for an object (e.g. turn 90 degrees left and move 2 meters) and the order makes a difference? What should the system do? How can we set up an experiment to see what it does?