r/howdidtheycodeit • u/MasterDisaster64 • Dec 09 '22
Question How did Sonic Adventure interpret input when running on walls/ceilings?
The Sonic Adventure games let the character run on walls, not as a distinct state like in many other games, but as a part of the basic physics. Anywhere the ground curves into a wall, you can run onto the wall and steer yourself freely on it. What I'm wondering is how the game translates your analog stick input to the direction Sonic should go.
Video examples: Emerald Coast, Speed Highway, Lost World, Pyramid Cave
If a wall is perpendicular to the camera, you move straight up the wall by holding forward, and steer left and right by holding in that direction. If the wall is sideways relative to the camera, you move forward or backward by holding in that direction, and steer vertivally by tilting left or right in a clockwise/counter-clockwise fashion. When inside a cylindrical tunnel, it's even possible to run a full loop through the tunnel by holding the same direction throughout. It all feels very intuitive (collision jank aside).
I assume the game uses an algorithm that takes in the stick input (Vector2), the surface normal (Vector3), and rotation of the camera (Quaternion), and returns the world-space direction Sonic should move (Vector3). I just don't know what that algorithm would be.
View all comments
Show parent comment
10
u/omegabobo Dec 10 '22
I'm pretty glad you linked the Celeste movement haha, I was hoping that's what it was.
I remember being really excited to see the source code for Celeste, expecting it to be really good, then seeing it and being disappointed it was more than 5000 lines of code in one file.
That's bad code, clearly, I thought. Now that I've been actually working in software for a few months, I can appreciate that it was probably the best solution given their circumstances.
I would argue though, that the dev (apparently just one guy?) probably knew what the algorithm was. Maybe not at every level but enough to where to look if something was behaving strangely. After enough time in a specific domain you just run into edge case after edge case and really can start piecing things together.