Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Loot Rascals

A TALE OF FRIENDSHIP, LOSS AND REDEMPTION... IN OUTER SPACE! · By Hollow Ponds

Controller movement issues

A topic by ardonite created Dec 08, 2016 Views: 420 Replies: 3
Viewing posts 1 to 3

I'm actually finding it harder to move in the patch than prior to the patch. Sometimes I'll try to move to the up+right hex and i end up in a different hex entirely.


I'm assuming this is because I asked for deadzone changes "Improved behaviour controller deadzone behaviour."

I'll post some code after my Daily about this....

Right now it feels like the deadzoning is being done per axis of the joypad, which will result in it feeling like its moving in a single axis when I am trying to move at a diagonal.

Not that this is pefect code, but here's what I'm doing on my current project. (V2 is a float[2], V2I is a int[2]). The relevant part is that it checks if the magnitude of the pair of axes exceeds the deadzone threshold, zeros it if it does and subtracts that much magnitude out otherwise.

Code provided "as-is"

V2I deadThumb(int ix, int iy)
{
   // was XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, but my older joypads were skidding with that.
   const int INPUT_DEADZONE = 11000;
   const int kMaxStickVal    = 32767; // positive or negative, post-deadzoning


   V2 thumb(ix + 0.5f, iy + 0.5f);


   //determine how far the controller is pushed
   float magnitude = thumb.length();
   const float kMaxMagnitude = kMaxStickVal + 0.49f;
   const float kNoiseMagnitude = INPUT_DEADZONE;
   if (magnitude > kMaxMagnitude)
   {
      thumb *= kMaxMagnitude / magnitude;
   }
   else if (magnitude < kNoiseMagnitude)
   {
      thumb = V2(0, 0);
   }
   else
   {
      // remove deadzone and renormalize
      float scalar = (magnitude - kNoiseMagnitude) / (kMaxMagnitude - kNoiseMagnitude);
      thumb *= kMaxMagnitude * scalar / magnitude;
   }


   V2I ret;
   ret.x = Math::round(thumb.x);
   ret.y = Math::round(thumb.y);


   return ret;
}

This is some very smart feedback, thanks! I'll see what I can do.

Yep, was able to have a better attempt at this, the results feel a whole load better to me. It'll go until the next build we do, would very much welcome your thoughts when that happens! Cheers.