don't click here

Sonic Physics Guide

Discussion in 'Fangaming Discussion' started by Lapper, Apr 1, 2021.

  1. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    [​IMG]
    The
    Sonic Physics Guide
    Created by Mercury.

    The Sonic Physics Guide is a comprehensive resource dedicated to describing the inner workings of the classic Genesis & Sega CD Sonic games, along with Sonic Mania. Here, the intricate details of how the game's physics function are thoroughly explored, providing in-depth explanations about the exact values and rules and precise speed values governing Sonic's movements, 360 slope physics, Badnik & object behaviour, all the way to the construction of the sloped terrain.

    It presents these physics rules in an engine-agnostic manner, focusing on the tangible results of the game logic instead of delving into the minutiae of how the original 68k assembly code operated. Displaying information purely to allow others to understand precisely what's happening and apply those principles to their own fan games. All while still making note of the quirks, limitations, and workarounds the original game had to make due to it's programming language.

    --

    I think many consider the classic Sonic "formula" perfect, and these games have spawned (and continue to spawn) so many fantastic fan projects, and I love to share this technical information in the most easily digestible way possible for the rest of those making their own Sonic frameworks and fan games.

    To that end, I've been rather dedicated over the last few years in updating and improving the guide, adding any information I find, diving into greater detail with specifics, adding images, or animated visual aid, and being sure information is presented as both general concepts for general application, and game accurate method breakdowns.

    --

    Some of the latest additions to the guide are
    • Refactoring pages
      • Solid Tiles page has been greatly changed, putting a great deal of detail into how sensors work. Information on how Sonic collides has been split into the individual sensors needed
      • Solid tiles has been split into 2 pages, as there was a great deal of slope physics information on a page about tile collision. Slope physics now has it's own page
      • Solid Terrain page, showing how Solid Tiles are used to build complex terrain, along with collision layers + layer switcher objects.
    • Slope physics
      • Extensive details about exact angle ranges used for slope physics with code examples
    • Plenty of imagery
      • Character specific sizes
      • Character hitboxes
      • Slope tile collision demonstrations
    • Game Loop information
      • Explaining the order of events for characters and in what order objects run their code
    • Detailed solid tile sensor information
      • Game accurate explanations of how a detected floor or wall translates into movement of the character
    • Game Object Solidity
      • Added brand new info about how objects behave solid
      • Sloped objects
      • Jump Through objects
      • Specific gimmicks (Seesaws, Flippers, etc)
    • Game Object hitboxes and movements
      • Badniks
      • Projectiles, Particles
    • Character Specific information
      • Character sizes
      • Character moves (with new collision info)
    • Game data
      • Pixels and subpixels
      • 256 angle vs 360 angle systems
    And more!

    I'm working on other elements that can go hand in hand with the guide, such as:
    • Lua script overlays for Gens (for all 3 games!) which show an approximation of player and object collision sizes and sensors, to help merge the concepts explained on the guide with actual gameplay to be easier to understand.
      The first two are out! https://info.sonicretro.org/SPG:Overlay_Scripts
    • I've also been exploring the lighter side of this research, creating a Twitter account to showcase off interesting or funny bugs, quirks, other nuggets of information, and visual examples of collision at:
      twitter.com/SonicPhysics

    I don't see much talk about the guide, here or elsewhere. But I know many people make use of it and I hope that more and more people are able to make great use of the guide for their projects as it improves!

    I hope this thread can allow more people to become aware of it, provide a place for feedback or requests, and to showcase new information and updates.
     
    Last edited: Jul 24, 2023
    • Like Like x 14
    • Informative Informative x 1
    • Useful Useful x 1
    • List
  2. I'm actually really looking forward to the example scripts you mentioned. I tried looking through the Physics guide a long time ago, and couldn't make head or tails of it at all. Making it a bit easier to understand with examples to show off what each part means should make it much easier to do things with it. Back when I gave it a look, I just gave up and decided to use discrete angles like Sonic Pocket Adventure with all of the various "physics" behaviors pre-baked into separate player states depending on what angle floor it's in contact with. Never did finish the project, but it did give me a lot more interest in the 8-bit games and wanting to see more fan-games based around those rather than imitating the Genesis games.
     
  3. Pexs

    Pexs

    Otherwise known as Spex Member
    As someone big into Sonic and big into Game Dev (but not big into ASM), thank you for the updates.
     
    • Like Like x 1
    • Agree Agree x 1
    • List
  4. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Holy crapperoni, this is going to be incredibly useful when I and my cohorts finally get off our asses and make that proper Sonic Worlds successor.
     
  5. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    https://info.sonicretro.org/SPG:Overlay_Scripts


    Here's a preview of that LUA overlay for Sonic 1 (for GensRR), it's pretty much going to be in line with the visual conventions set by the guide imagery. Each element like hitboxes, solid sizes and names can be toggled on and off. This is purely aimed to help visualise the things written on the guide more easily.

    One thing it has brought to light for me is that objects are coded very inconsistently, some define their sizes ahead of time as they should and where the overlay code can read it easily, some just do it on the fly (which means I have to manually do the same for the overlay). Some use the general hitbox system, some don't. Some stuff has to be manually manipulated to get the best result but ideally a good representation of what is going on is the aim.
     
    Last edited: May 4, 2021
    • Like Like x 1
    • Useful Useful x 1
    • List
  6. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    https://info.sonicretro.org/SPG:Overlay_Scripts


    Wanted to show some progress with the Physics Guide Gens Re-Recording overlay Lua script.

    Notable changes:
    • The script reads values as the game code is executed, something it didn't do before (before the focus was more on displaying the object variables, but now it does that and also shows visual representations of the processes going on), giving an extremely accurate representation of Solid Objects for example.
      • Solid Objects show up as green, while the actual object sizes (Width/Height Radius) show up as yellow (the sizes are not enabled in the video).
    • All solid tile sensors of all objects (such as enemies, and falling rings or item monitors) are now on display and visible. Again, read directly as they are executed.
      • Also, there is an option to smooth out things like sensors. This isn't accurate but without it sensors and boxes will appear to shake. Basically on a given frame Sonic moves forward, casts a sensor to find the floor height, if running up a slope the sensor might have been cast inside the floor. Then Sonic moves up to where the floor surface was found. Well, now you have a sensor inside the floor while Sonic isn't, and that might look shaky. It's accurate, but shaky, and the same applies to any moving object. So you can choose to "correct" this, which looks nicer but with diminished accuracy of where the sensors were actually cast that frame.
    • Objects with slopes now display the slope array, directly from the game data.
    • When you stand on any object, the left and right boundaries for Sonic staying on the object (which varies, sometimes it extends past the sides, sometimes it does not) is properly indicated with a horizontal line. If Sonic moves past the ends of the line he will fall off.
      • The box of an object does not appear when standing on it because the code for coming into contact with said object doesn't run when you are on it.
    • There's a minimal amount of manual manipulation of visual information now, the only things added manually are the names of objects and the random collision boxes that aren't defined or run through a subroutine - like the trigger for a checkpoint, endpost, or active area of a SLZ fan.
    • Solid Tiles are now visible thanks to Mercury, a way to show the tile properties is also in there.
    The script will be released in the near future.


    By the way, It's posting this sort of thing that makes me wonder if this should be in the hacking section, but the intent is to aid those creating fan games/frameworks so, I assume those people are just as if not more interested.
     
    Last edited: May 4, 2021
    • Like Like x 4
    • Useful Useful x 1
    • List
  7. Aerosol

    Aerosol

    Not here. Moderator
    11,163
    573
    93
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    It's a bit of a grey area. I don't see a problem with it being here though.

    You're doing God's work dude. Amazing stuff!
     
  8. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    The SPG Sonic 1 (REV01) Collision Overlay Script is here!
    https://info.sonicretro.org/SPG:Overlay_Scripts

    Shows sensors, terrain tiles, hitboxes, solid boxes, object sizes, object variables and more
    Will only work correctly with REV01!

    Credit to Mercury for the solid tile drawing and assistance.


    Give it a try, using Gens Re-Recording!
     
    Last edited: Jan 29, 2023
    • Like Like x 5
    • Useful Useful x 1
    • List
  9. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Okay, this is super impressive! Used this to suss out some details from the guide while making Sonic Worlds Next.
     
  10. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Good to know:) Best use for this is to check fangame stuff against it and better understand the guide.

    Anyone who uses this, if you spot anything amiss, or missing, or just have questions about what you're seeing feel free to let me know.
    Meanwhile
    [​IMG]
     
    • Like Like x 3
    • Useful Useful x 1
    • List
  11. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Little bump but -

    Yeah wow, all makes sense now. Or maybe there are just more questions, like was this deliberate.
    [​IMG]

    Not sure how long the S2 version of the overlay will be but I am posting some interesting finds on Twitter @SonicTeardown if you are interested.
     
    • Like Like x 1
    • Useful Useful x 1
    • List
  12. Xiao Hayes

    Xiao Hayes

    Classic Eggman art Member
    Since there's two "layers" of solid terrain, would it be possible to colour them differently?
     
  13. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Sonic 1 didn't work that way. Sonic 2 and Sonic 3K used two collision planes with swapper objects, Sonic 1 used some hardcoded stuff.
     
    • Informative Informative x 2
    • List
  14. Xiao Hayes

    Xiao Hayes

    Classic Eggman art Member
    Oh, I knew block mappings were different in Sonic 1, but I thought layering was already there. I should check out what I got wrong. What does the "solid white vs. transparent white" colouring mean in what Lapper did, then?
     
  15. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    You're right that there's separate "layers" to the loop but it's special specific chunks only.
    The terrain part wasn't my work but you're in luck, the script has been updated to only show the relevant tiles on the loop chunks (thanks Mercury, again), just download it from the page again and it should be good to go.
     
    Last edited: May 4, 2021
    • Informative Informative x 1
    • List
  16. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    • Like Like x 3
    • Useful Useful x 1
    • List
  17. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    All Physics Guide pages now have a menu to the right showing all the guide pages, allowing for very quick and easy navigation throughout the entire guide.
    [​IMG]
     
    • Useful Useful x 3
    • Like Like x 1
    • List
  18. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    The Sonic 1 Collision overlay is currently going through some (hopefully) final upgrades before the Sonic 2 version moves forward.

    The changes coming soon are:
    • Platform object collisions now have their own colour to distinguish from normal solids.
    • Hitbox reaction types are now colourcoded (pink for badnik, red for hurt etc)
    • Sloped platform objects and sloped solid objects are now depicted consistent with normal platforms and solids (they definitely were not before)
    • Sensor distances found by the player are displayed in realtime
    • A couple new variables are displayed (control lock and stick to convex)
    • Bridges now have their platform collision properly displayed, and a fix for some checkpoints not showing their trigger area
    • The interface is slightly updated

    [​IMG]

    There's a little vid of it in progress here:
    https://twitter.com/SonicTeardown/status/1417865462382223362
     
    • Like Like x 4
    • Useful Useful x 1
    • List
  19. Candescence

    Candescence

    Member
    2,023
    21
    18
    Sydney, Australia
    3D Indie Stuff
    The Physics Guide was neat before, but holy cow is it so much better and more informative now. Brilliant work, mate.

    (That being said, implementing in an actual game engine is easier said than done, I'm trying to do it myself in Unity and oh god it's a mess. The sensors can easily be replaced by raycasting and I've set 1 pixel per unit to keep conditions accurate, but the physics are still completely off. The player can jump and collide properly, but once the ground angle stops being zero everything goes haywire.)
     
  20. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Awesome! Hopefully it can keep getting more simple & understandable.

    In the overlay update tiles will be colourcoded (still deciding on the default colours), many more variables will be available. Also, you can see the angles for each tile
    [​IMG]
    [​IMG]

    [​IMG]