Sonic Totem

Discussion in 'Fangaming Discussion' started by SABrown, Sep 29, 2018.

  1. SABrown

    SABrown

    Member
    7
    4
    3
    Hi everyone. Over the past year, I've been working away at my first fangame - a demo built within Unity called Sonic Totem. Development started around the launch of Sonic Mania, and barring a break between February and June I've been working on it in my spare time. This is my first time doing anything like this - Knew I wanted to learn C# and thought this would be a perfect means to that end. The demo I've just released (V1.01) contains two zones, the first of which has a boss fight at the end. I'm aware that the Physics is a bit off - it's something that's on my to-do list, and I've found it quite tricky to replicate the OG physics engine in Unity, but... it's playable! ^_^; Future work that will go into this will mainly depend on my spare time, and things may be about to get busy again, hence why I'm publishing this build now. I've done all the scripting independently, and when I go back to it I'd like to completely overhaul the main character controller script.

    The concept is as such: Dr Eggman has learned of the Catastrophe Totems, ancient devices rumoured to be able to control the forces of nature. The evil doctor realises with these powers he can hold the world to ransom - literally through rain, snow and shine. After finding the primary control totem in the game's opening act (Firewood Forest), it's up to Sonic to find the other totems first, prevent Eggman from building the Egg Totem, and avert an environmental disaster.

    You can watch the trailer here:


    Additionally, full gameplay videos of both zones can be found on my youtube channel. You can download the demo, playable in Mac or Windows environments here:
    https://www.dropbox.com/sh/gqzv4wwf751sv10/AAAX28wCxhf-TKmOF4nDzHD0a?dl=0

    Input is with the Keyboard. At the main menu, you can press "M" to toggle music (As personally I prefer to play the first zone with "Windy Hill" from Sonic Adventure and the second with "A little light snowfall" from Yoshi's Woolly World), or "C" to reset the player data. Press Esc in-game to open up the menu.

    Let me know what you think! Is this something you'd like to see more of in the future?
    This is my first time doing anything like this so.. uh, please be kind haha.
     
  2. Noah Copeland

    Noah Copeland

    Member
    38
    18
    8
    Haven't had a chance to play it yet but I have to say, the game looks very original visually. Nice environmental effects like the leaves. Nice zone tropes that aren't the norm as well. Bonus points for aurora borealis.

    "I'm aware that the Physics is a bit off"
    This is very reassuring to hear ^^^
    You'd be surprised how many people making games are unable to see the obvious shortcoming in their work. As long as you are aware, that puts me at ease. And yes, replicating those physics is no easy task. If I'm not mistaken, I think Tpot was able to get a decent Sonic engine working in Unity, but don't quote me on that XD

    :thumbsup:






    ./>
     
  3. winterhell

    winterhell

    Member
    1,162
    6
    18
    Very cool!
     
  4. Flare

    Flare

    Member
    714
    4
    18
    Getting some Donkey Kong Country Returns / Tropical Freeze vibes from the level design. Which is refreshing to see.
     
  5. SABrown

    SABrown

    Member
    7
    4
    3
    Thanks for the comments guys! Especially @Noah it means a lot that my concepts delivered - I've tried to go with some fresh tropes that haven't really been used that much within the series.

    I'm happy to also announce that I've already began work at redesigning the Physics engine, and although it'll take time to reconfigure the world around Sonic, I've already got him moving -much- more akin to the original games, and many of the Physics problems in the current build are pretty much gone now :) . It'll take some time to rebuild the other stuff, but in a few months I should be able to provide an update!

    I'm really happy to know that people are interested in the project :)
     
  6. Lapper

    Lapper

    Member
    1,584
    155
    43
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy: WW, Freedom Planet
    Wow loving this - using colours and particles really well - such good atmos and even immersion. Something so unique about it!
    Very awesome.
     
  7. The art and animations are so awesome, and the zones looks so pretty. However, the physics, by what I saw on videos, really needs alot of work. Do that and this will become a masterpiece, and honestly the distance of the camera doesnt bother me. Amazing job
     
  8. SABrown

    SABrown

    Member
    7
    4
    3
    Hey everyone - been a while!

    So I'm still hacking away at this project. The Sonic Physics guide on the site has been an utter godsend, so much so that I cringe seeing the Physics in the first build of this game. Roughly, things are going pretty well now - however, I've been tearing my hair out over one specific quirk of my interpretation of the guide, and I could really use some help.

    Imagine a big circle and imagine Sonic is traversing it. If he's running alongside the interior of the circle, I have absolutely no issues with the 4-quadrant approach outlined in the Physics guide, and he'll happily switch from floor to wall to ceiling to wall to floor again in a circle. The issue I'm having is with exterior curves (traversing the outside surface of the circle), particularly when the ground slopes away from Sonic greater than 45 degrees to his local direction. Here's a video to help:



    So he's running on the ceiling. His quadrant is initially 2, and his Rays are casting upwards. While this is true, the raycast chosen to position the player is the one that returns the minimal y co-ordinate (So that would be the trailing cyan ray). Once the cyan ray hits the ground that has an angle of < 135deg, it switches the quadrant back into Right Wall mode (1) where the Rays begin casting to the Right, but here's the crux of the issue: The rightwards-directed rays immediately cast back to the tiles he just cleared, detecting the ceiling angle and popping him straight back into ceiling mode. This tug of war happens for a few frames before all the popping de-grounds him.

    I've found this issue generally appearing anywhere I go over an exterior curve that slopes away from the player. I've tried a load of things to fix this, including detecting these cases and using a single Raycast directed across the Inverse Normal, but nothing's solved it in a tidy way. I could really use some guidance to resolve this - especially because a lot of the physics works so well now, it's disheartening to be so close but yet so far! :( Has anyone else had similar issues and managed to resolve them?

    Some Background Info:
    A) I don't use the Hex/Tile formalisms described in the guide, as I'm using Unity's own Tilemapper. I'm not sure if this should be problematic - the Raycasts shouldn't care about how the ground's collider is divided up, right?
    B) I'm using Unity mainly because this was my first game project, and I wanted to work in an environment that was more general purpose.

    @Lapper - Thanks so much, this means a lot coming from the work I've seen you do! If you have any insights it'd be awesome
     
    Last edited: Apr 1, 2020
  9. Lapper

    Lapper

    Member
    1,584
    155
    43
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy: WW, Freedom Planet
    It looks like the red ray is the one that's being used to position him right at the start of the vid, while it should be the blue? He seems to start inside the ground as a result.

    Of course, on the ceiling it's flipped so it's the maximum y value (lowest) instead of the minimum (highest). Same on walls. General rule is it's the closest to Sonic's position along the axis. Maybe this could be explained better on the guide, I forget.

    I might be wrong about it being the cause, though.
     
  10. AeroGP

    AeroGP

    Member
    128
    1
    18
    Los Angeles, CA
    Sonic for GameMaker: Studio
    This sounds like a symptom of the method of floor switching clashing with your method of angle acquisition. It could be that you're using greater/less than or equal to tests where you shouldn't, and the angle found in both modes is the same, so it can't make up its mind which floor mode to stick to. This would cause the behavior you're describing. It's hard to judge from just a video alone, though. Maybe a code snippet of what you're doing at that particular moment?
     
  11. SABrown

    SABrown

    Member
    7
    4
    3
    Thanks for the comments guys - still hammering away at this and it's driving me nuts. I think what gets to me is that the approach works great for interior curves, just not exterior ones. I still think the problem is that, on an exterior curve, when you change quadrant, the quadrant you change to wants to raycast in the direction you just came from - so if my player isn't moving fast enough, they won't have cleared enough distance to safely ensure that they'll detect a tile belonging to the quadrant they just changed to.

    i.e, in the example above, what's happening is
    • Running on top of ceiling, Quadrant = 2, Rays are casting Upwards.
    • Leading Ray detects a change in quadrant to RightWall mode (Q=1), but is not used for positioning as it's hit a higher y-value, and on the ceiling the lower y-value should be used
    • Once the trailing (positioning) ray also picks up the change in quadrant, then the player's quadrant is successfully changed to Right Wall mode (Q=1)
    • Now in right wall mode, Raycasts are fired off to the right (in the direction the player just came from), but because the player hasn't cleared enough vertical distance, they just find the tiles that the player recently left, which have a Quadrant of 2 (Ceiling), and it boots the player back into Ceiling mode again, Raycasting upwards...
    This is never an issue in interior loops because when the quadrant changes, the rays are cast in the direction of the player's travel.

    I've been fiddling with everything trying to troubleshoot this - Am I right in that Ground Raycasting should only influence the player's position along one axis? (i.e, if you're standing upright, the ray will only be used for positioning the player's y co-ordinate, with the x axis being solely influenced by the players x-velocity)

    Sorry if I'm being really dense! Was just hoping others had maybe come across this before :ohdear:

    Cheers - I've been looking and looking at this though and it'll have definitely been the cyan ray positioning him (in that video, his "position" is pretty much smack bang inside his fist, it's just the rotation of the sprite being misleading there, I think.

    The thing is though, I use the same method as in the Physics Guide to calculate Quadrant Value from the angle (In degrees):
    quadrant = Mathf.RoundToInt(theta / 90) % 4;
    I think it's more to do with the immediate detection of the previous quadrant when the quadrant changes on the exterior loop - cheers though.
     
    Last edited: Apr 3, 2020
  12. Lapper

    Lapper

    Member
    1,584
    155
    43
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy: WW, Freedom Planet
    It's using the red?

    [​IMG]
    It should definitely be the blue that is the 'winning sensor' in this situation though, while in ceiling mode. Blue would find ground closest to Sonic on this curve. Not that I think this is the root of the problem you're having because it does seem weird and probably goes deeper - but if the sensor on the ceiling used is the higher one he would go deep into the floor like this.
     
  13. SABrown

    SABrown

    Member
    7
    4
    3
    Oh man - sorry! Nope, it's the cyan one being used (wasn't looking at the video while writing my post >_< apologies)
     
  14. AeroGP

    AeroGP

    Member
    128
    1
    18
    Los Angeles, CA
    Sonic for GameMaker: Studio
    EDIT:

    I see what you mean.
     
  15. RetroRespecter

    RetroRespecter

    Member
    25
    1
    3
    Okay. I'm blown away by what I saw. What features are you using or creating?
     
  16. SABrown

    SABrown

    Member
    7
    4
    3
    Finally, some luck! Thanks to everyone who helped me out on this - made a breakthrough last week thanks to ShadowMasterX5 on youtube pointing me towards the UniSonic engine made by Giometric. Both of our engines were following the SPG on here, but my order of operation was missing one wee trick - Quadrant updates based on new terrain found in the current frame should not happen until the player is being positioned, with the height/point on the new terrain being applied to positioning via the quadrant in the previous frame. My previous mistake was immediately applying the new quadrant at the time of Raycasting

    Thanks everyone who looked into this - and thanks to Giometric's engine as a useful reference. I've refactored my code so it roughly follows the same order. Really excited to get into the meatier parts of this now and hopefully have some new stuff to show soon :D