Project 1B: Barrel Bouncer (Interactions)

Part 2: Creating a More Realistic Player Controller

In class, we looked at some of the inheritent problems with using Transform methods to apply movement to a player when it has a Rigidbody and is affected by physics. In this section, you will be revising your player controller to take advantage of the Rigidbody properties and methods and also implement a few new aspects of physics-related functionality.

Setup

There are a few changes we will want to make to our player GameObject, as follows:

Scripting Requirements

Unchanged Requirements from Project 1A

Below are the requirements for the player controller of project 1A that still hold for this project:

Additional Requirements

Additionally, there are some new requirements introduced for your player controller script in this project.

Tips on Implementation

Jumping

Rather than trying to detect if you’re on the ground from the Player Controller script (since you could be colliding with many other GameObjects even when you’re not on the ground, such as sliding off a wall or tree when you’re in mid-air), you could attach a script to the Feet GameObject to accomplish this (since its box collider is less wide/deep than the capsule’s and only present at its bottom point). You would then need to design a way to access this “grounded” information from the PlayerController script in order to implement jumping.

Respawning After Death

You should detect the trigger underneath the environment using the Player Controller script that’s attached to the Player GameObject. If you simply tried to implement this script on the Feet GameObject, it would not work since two triggers cannot detect each other; at least one must be a non-trigger collider for a collision/trigger event to be fired.

Previous Section | Go Home | Next Section