Professional Documents
Culture Documents
1. Player Movement
To implement player movement, a basic script should be placed on the player object or player
controller. This script should contain variables to track the current movement type (sprint,
crouch, prone, default), as well as a series of branching conditional or switch statements. These
statements should work in such a way that when the player presses or holds down a particular
movement key, the statement sets the variable for the previous movement type to zero and sets
the variable for the new movement type to one. For example, if the player is using default
movement and then holds down the sprint key, the default movement variable should be set to
2. Weapon Behavior
To implement proper weapon behavior, a bullet system script should be written, along with a
unique weapon script for each of the weapons that the player can use in the game. The bullet
system script should include any universal bullet behavior that will be true regardless of the
weapon that is being used. The bullet behavior script should not use the ray casting method,
which simply projects an invisible ray directly in front of the player object and does not account
for any recoil. Instead, this script should make use of rigid bodies, which are physical objects
within the game world that can behave according to the laws of physics. The script should
spawn a small rigid body object directly in front of the chamber of the player’s weapon
whenever the player fires their weapon, assuming that the weapon is loaded. This will give the
illusion that bullets are coming out of the chamber. This script should also contain a loop that
iterates as long as the player is holding down the fire button. Each time the loop iterates, a
Johnson 1
variable tracking the recoil amount should count up. This in turn should cause the player’s aim
to gradually move off target. In terms of individual specialized weapon behavior scripts, each of
these scripts should keep track of things like maximum ammo capacity, current ammo capacity,
and weapon fire mode (either single shot, semi-automatic, or fully automatic). Additionally,
each specific script should contain a variable or some such way to track which type of weapon it
is. This will ensure that, for example, if the player is using a sniper rifle, they can use the zoom
feature to see targets further away, and if the player is using weapons like light machine guns,
submachine guns, assault rifles, or pistols, the player will be able to aim down their sites or their
smaller magnification scope, but will not be able to zoom to the degree they would with a sniper
rifle. Once the appropriate scripts have been created, a test environment should be created that
contains the player controller, the weapons, and one or more targets to fire at. The targets should
have a script that tracks if a bullet has hit it or not. If it has, then the target script should output a
message to the console saying that it was hit. This will allow for testing of hit or bullet
registration.
3. Player Damage
To implement the player damage system, the player controller object should be split up into
multiple sub-objects that are children of the player object. The original player object will still
exist and contain the player movement script, but the actual physical parts of that object should
be split up. The sub-objects should be grouped into the areas of the player’s legs, arms, torso,
and head. This will eventually allow for tracking of where on the body the player was damaged,
and allow for an appropriate health reduction. Once the objects have been split up, a player
damage script should be created and placed on the player object, but not any of its children. This
Johnson 2
script should contain variables for the legs, arms, torso, and head. The script should work in
such a way that when a bullet hits the player, the script should track where on the player the
bullet impacted, and then reduce the player’s health by a different amount depending on the
impact area. For example, if a bullet hits the player in one of their arms, the script sets the arm
variable to one and subtracts player health by one quarter, whereas if a bullet hits the player in
the head, the head variable should be set to one and the player should be killed. Additionally, if
a bullet hits the player in an area other than their head, and if the damage caused by the bullet is
not enough to fully deplete any remaining health, the script should start an invisible timer that
begins a few seconds after the player is hit. While the timer is running, health should be
subtracted from the player. This timer and gradual health loss is meant to simulate bleeding out
in real life. The only way the timer can be stopped is if the player presses the heal key, assuming
that they have at least one bandage. The script should keep track of the number of bandages that
the player has and if they have at least one, stop the timer and health loss, if not, continue the
timer. After the script has been fully written, the player controller object and its children should
again be placed in a testing environment. The environment should contain four other objects that
spawn projectiles. Each object should have a script on it that targets the projectiles at a specific
section of the player object, so there should be one object firing projectiles at the head, torso,
arms, and legs respectively. When the player gets hit, a message should be output to the console
saying which area the player was hit in, and saying the health reduction amount. This allows
testers to track if bullets are registering as hitting each of the areas and if the appropriate damage
Johnson 3
Player Choice: To implement player choice into the game, a separate player choice script should
be written that contains a series of branching decision trees. Essentially the script should
function via one or more different loops (while loop, for loop, do while loop) in such a way so
that, for example, if the player makes choice A then present them with result B, if the player
makes choice X then present them with result Y, etc. The script should save player decisions
from level to level, so this script would either be placed on the player controller object, or on
some sort of invisible script object meant to hold key game scripts that allow for general
functionality.
Johnson 4