In this assignment, you will design and implement a very simple game physics engine, tuned toward platformer games. This will increase your practical understanding of:
Physics engines in games are responsible for the movement of bodies in response to forces, the detection of collisions between bodies, and computation of the response to collisions. In this assignment, you will complete a very simple 2D physics engine, and use it in a simple platformer game.
The engine permits the application of forces to 2D rigid bodies. It detects when bodies collide, and modifies the velocity of bodies when they collide.
The engine makes several significant simplifying assumptions. Only linear motion is considered - bodies do not rotate. For the purposes of collision detection, each body is represented by an axis-aligned bounding box (i.e., a rectangle.) No provision is provided for constraints such as hinges or pistons.
Complete a set of classes implementing a simple 2D physics engine. Base your engine on the provided code. A PPhysicsBody component can be added to any game object to place it under control of the physics engine. The core method used by games to move rigid bodies is ApplyForce, which applies a force of a given magnitude and direction to the body. The PPhysicsBody provides a number of properties that game programmers can set:
A PPhysicsEngine component implements the physics engine itself. It updates on Unity's FixedUpdate cycle. On each invocation of the physics engine, it performs an integration step on each physics body, detects any collisions, and resolves those collisions.
To illustrate the use of the physics engine, I have provided a simple platformer game, shown in the above video.
Extend this game to include at least one new, interesting feature. For example, you might include a "box gun" which fires little boxes at a random angle into the path of the avatar, or a "puff platform" which emits random upward gusts of wind, or a puzzle platform which can only be solved by pushing boxes into the right place. Describe your novel feature and explain how you implemented it. This part of the assignment will be graded both on the technical correctness of your addition to the game and the imagination and scope behind the extension.
Code to get you started is attached to the assignment description in OnQ.
Provide brief answers to the following questions.
There are many extensions you could make to this assignment. You are unlikely to have time for these now, but if you are interested in learning more about game physics, you could tackle them once term is done. There is no extra credit for doing any of these extensions - they are purely for fun and learning.
Using OnQ, provide a hand-in consisting of two parts: (1) your code for parts 1 and 2, and (2) a report answering the questions from part 3.
Your modified code should be a zip file containing a folder called physics-yourLastName. That folder should contain your full running solution to parts 1 and 2, as a Unity project. If your project doesn't work, include a description in your report specifying what does and does not work. Note that this should be a zip file, not a rar file, or other compression technology.
Your report should be in PDF format. It should include your name and a title (e.g., Assignment 3 Report). Use 11 pt type with at least 1" margins. UML diagrams should be included in this report, not submitted separately as raw UMLet files.
This assignment will be graded using the rubric posted on OnQ. It is advisable to review this rubric in advance of submitting your work.