Monday, April 29, 2024
HomeGame Developmentunity - Automated playtesting in a 2D platformer

unity – Automated playtesting in a 2D platformer


For a hard 2D platformer I’m working on, I want to make an automated playtesting system. The goal is to allow every level to be tested in parallel as part of an automated test suite. These tests would both help to catch bugs and determine if a level is still possible to beat after any given change, which could both be huge time savers in a game that could take a few hours to finish.

How do other games approach this?

My initial approach has been to record some inputs I use to finish a level, and then replay those inputs in the test. Specifically, every frame I check if the input state is different from the last recorded input state, and if it is, save it along with a timestamp relative to when the player spawns into the level. Replays simply set the input state according to those timestamps.

This works maybe a quarter of the time. I suspect the issue is that small fluctuations in floating point math add up pretty quickly, and the input recordings make a lot of assumptions as to where the player is at any given frame which may not be true due to those deviations. (I also thought it might have to do with variable frame rate, but I didn’t see any improvement from switching to FixedUpdate.)

I have a couple ideas for how to fix this, but they all have cons:

  1. Implement an AI. A fully autonomous agent is overkill; a more realistic alternative might take the input recordings and make small adjustments in real time, but that would still be a lot of work to make
  2. Fudge things. Record the state of every entity, and if it deviates enough during a replay, set it back to the recorded value. This smells bad to me – it feels like in this case, the behavior I’m testing is different enough from actual gameplay that the tests lose a lot of their value
  3. Explore deterministic physics. I’ve found approaches like this, but I’m not sure if they’re relevant for my game – I only use Unity’s physics for collisions (everything else is hand-rolled to avoid generic gamefeel), and I’m already loading the scene fresh at the start of each test, so I’m not sure what else could be achieved with a reload. I absolutely could be missing something, though

What else haven’t I considered?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments