0
\$\begingroup\$

I am trying to implement a twin stick shooter game, sometimes referred to as dual stick shooter where the left stick controls movement, and the right stick aims a gun.

What I do now, is directly map the stick angle to the gun angle, if the deflection is large enough. In pseudo code:

// jx in [-1,1]
// jy in [-1,1]
if lenght (jx,jy) > 0.5 :
    gun_angle = toangle( jx, jy )

This gives a very unsmoothed, twitchy signal for the aim.

The gun can flicker in any direction in a single frame.

In theory, the most responsive scheme, but on-screen looks far too twitchy.

So I wonder: should I sacrifice some responsiveness for a smoother signal?

Should I make the gun swivel around as I reverse the direction of the joystick, or just set it hard, like I do now?

I've been considering using the stick signal as input to a PID controller that does the actual gun rotation, but would like to know whether that's an appropriate solution for this application.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I've played dual-stick shooters where the rotation is instant as you describe, and other dual-stick shooters where the character/barrel has a maximum turning rate. Both seem to be viable ways to make such a game. So the route you choose may just be up to your own player experience goals and design judgement. Which is more important to the specific game you're making - responsiveness or smoothness of animation? Or are you willing to sacrifice a little plausibility to get both, showing smooth rotation while changing the direction of shooting instantly? \$\endgroup\$
    – DMGregory
    Commented Sep 29, 2018 at 11:55

2 Answers 2

2
\$\begingroup\$

The general rule of thumb in game design is that it is better for a game to feel right than to be right. So smoothing out the gun movement can be a viable method to make it appear less twitchy. I am not sure, though, if using a proportional–integral–derivative controller is the best technique here. Have you considered just taking the average of the past few input measurements? However, without actually playing or even seeing your game, I am just guessing here.

Another thing you might want to experiment with is the size of the deadzone of your firing thumb stick. When you give a shooting signal even if the stick is just moving a tiny bit away from the center, you will get a lot of unintentional "phantom shots" in random directions even if the player's firing finger is just resting. So you might want to define a minimum distance from the center which is required to trigger a shot. Keep in mind that not all gamepads are the same, so you might want to make the deadzone size configurable.

\$\endgroup\$
1
\$\begingroup\$

You always have the option of slowing down the responsiveness, by limiting hte speed at which the character can turn as you mentioned; but there is also another possibility if the game play is feeling 'perfect' with the current responsiveness: You could instead slow down the animation to blend better while maintaining the game play responsiveness, for example by having the body of the character turn at a maximum speed while the arm holding the gun could swivel past that and effectively cover the full range when both are used together.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .