Giter VIP home page Giter VIP logo

unisonic's Introduction

UniSonic

A simple implementation of Sonic the Hedgehog's physics and movement controls in Unity. Done as a learning project a while back, opened up the repo so anyone interested could check it out.

Based on the excellent information found at http://info.sonicretro.org/Sonic_Physics_Guide

The implementation is followed fairly closely, though using raycasts instead of direct reading of tile data. This makes it more flexible, but does mean that tile-specific colliders need to be created for any new tiles that are added. Using tile data directly may be added as an extra feature later, but would still rely on raycasting to find which tiles are nearby.

One consequence of using plain 2d raycasts is that any kind of collider Unity supports will work. In the demo level I use a few tilemaps for most of the environment layers, and a couple of Sprite Shape objects as well. The layer switch triggers are BoxCollider2D objects.

SonicGif

Controls

Movement is done with WASD, Space to jump. Tab opens and closes the debug UI on the top-left of the screen. R will reset Sonic to his start location, and holding Left-Shift will activate a super-acceleration mode.

All input is done via Unity's old InputManager, and the mappings can be edited from there (Project Settings > Input Manager).

Implemented

  • General ground and air movement
  • Jumping
  • Camera
  • Underwater ground/air movement
  • Slopes, running up and attaching to walls/ceilings
  • Rolling
  • Animation (done via Mecanim states)
  • One-way platforms
  • Loops and collision layer switching
    • This has some minor issues, mostly requiring some care when placing the switch triggers
  • Smooth rotation for Sonic, like what the Sonic Advance games do, is supported and can be enabled via a checkbox on the Sonic prefab; turned off by default
  • Looking up and down
  • Losing rings when hit
  • Interactable objects
    • Springs
    • Simple damage trigger
    • Rings
  • Spin-dashing
  • Balancing animation when standing near ledges

Missing Features

  • More enemies, moving enemies etc
  • Other interactables
  • Pushing

Notes

  • Sonic the Hedgehog belongs to Sega.
  • Sonic Sprites by Shinbs, with some additional credits; obtained from spriters-resource.com: https://www.spriters-resource.com/custom_edited/sonicthehedgehogcustoms/sheet/111542/. Previously was using ripped Sonic 3 sprites, but these look great and won't get anyone in trouble for copyright :)
    • New sprites should be relatively easy to put in if desired, but Unity animates sprite swaps via direct references to the assets. To fully swap out all the animations, all the animation clips would need to be updated (or new ones created).
  • Pixels-per-unit setting of 1 was used to make it easier to map values from the guide to Unity units. Newly-added sprites should have the same setting, so pixels are consistently the same size.
  • Project uses Unity 2021.3.4 (the 2021 LTS).
  • SpriteShape and Tilemap are used in the test level, but aren't necessary for this implementation to work. Collisions work off of Raycast2D so any type of collision will work.
    • If mixing rigidbody-simulated objects in, note that they will likely behave strangely due to the funky scale.
  • As this is based on the original implementation of Sonic's physics from the Sega Genesis games, it does also include some of the same bugs. For instance, it is impossible to stand on the center of very thin platforms.
  • The project folder contains a handful of unfinished bits of code or not-yet-used assets. If something looks like it's not getting used, there's a good chance it isn't just yet.

unisonic's People

Contributors

giometric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.