I’m now using the “topmost lines” algorithm that I demonstrated in the last episode to handle player movement.

I want to try something new this episode and post my “script”. Posting this is considerably easier than transcribing the finished episode. So I’m hoping that this is useful for people who have asked for transcripts in the past.

Please let me know if this is useful to you?


Video Script:

  • Last time on the DevLog:
  • I showed you my topmost lines algorithm
  • Now I’m actually using it to handle player movement
  • So, recall that the player is modelled as a hovering rectangle
    • I need to figure out how high off the ground it is, so I can move it up or down to the correct hover position
  • Before, to get that distance, I was sampling from either one or two points on the ground below the player
    • Now I sample the entire area below the player and take the average height
  • While I was tuning this, I tried out a bunch of other sampling schemes
    • For example: here I’m generating left and right foot positions by extrapolating lines to the foot locations on each side and then taking weighted averages for each foot
  • But it turns out that a simple average within an adaptive window gives the best results
  • This already fixes some of the errors that were caused by the point sampling
    • This is the old method glitching out
    • And here is the same set of inputs with the new method
  • But there’s still a lot of glitches to fix up
  • And part of the point of switching to an area sampling method is that I can do some clever things with the networking to make these glitches go away
  • Another bonus is that it will help with animation
    • Basically allowing me to place the stick figures’ feet exactly on the terrain as they run
  • Because this area sampling has worked so well for the feet, I’m thinking of trying it for the left and right sides, as well as the top of the player
    • This would let me implement similar glitch protection for left and right player movement
    • As well as fancier animations and better wall jumping
  • It also raises the possibility of removing the player from the physics engine all together
    • Which would be a big performance win
    • And it will avoid all the annoying cases where the physics engine fights with my custom platformer movement
  • So hopefully I’ll be able to show you some of that next episode
  • As usual, subscribe to my blog or follow me on Twitter
  • And go to StickNinjas.com and sign up to be notified when Stick Ninjas is available for playable pre-order
  • Thanks for watching