Game Development Reference
In-Depth Information
movement would require the player to push the thumbstick all the way out of the
dead zone. That would make it almost impossible to aim properly.
The dead zone shape also doesn
t have to be exactly what you see in Figure 9.2.
Depending on your game and how people play it, you might change the shape by
making the angle shallower or even pull the left and right dead areas away from the
center, giving the player complete control over camera pitch until the thumbstick
is closer to the extreme right or left side. The only way to figure out the perfect
shape is by watching a lot of people play your game and seeing what they do that
frustrates them. Controls that are too sensitive or too sluggish will frustrate players,
and you
'
'
ll want to find a middle ground that pleases a majority of people.
There
s one additional trick to this solution. Think about what happens when the
thumbstick moves away from the dead zone into the active, clear zone. One thing
players expect in all control schemes is continuous, predictive movement. This
means that you can
'
t just force the Y value to zero in the dead zone and use regular
values everywhere else; you have to smoothly interpolate the Y values outside of the
dead zone from 0.0 to 1.0, or the player will notice a pop in the movement of the
camera pitch. The code to do this is not nearly as bad as you might think:
'
float Interpolate(float normalizedValue, float begin, float end)
{
// first check input values
assert(normalizedValue>=0.0f);
assert(normalizedValue<=1.0f);
assert(end>begin);
return ( normalizedValue * (end - begin) ) + begin;
}
void MapYDeadZone(Vec3 &input, float deadZone)
{
if (deadZone>=1.0f)
return;
// The dead zone is assumed to be zero close to the origin
// so we have to interpolate to find the right dead zone for
// our current value of X.
float actualDeadZone = Interpolate(fabs(input.x), 0.0f, deadZone);
if (fabs(input.y) < actualDeadZone)
{
Search WWH ::




Custom Search