Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

[Released] 2D Platform Controller

Discussion in 'Assets and Asset Store' started by JohnnyA, Mar 11, 2013.

  1. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    The 2D platform controller has now been deprecated in its place is our new and powerful kit: Platformer PRO

    Get Platformer PRO on the Asset Store

    Read more here:

    Platformer PRO forum post



    - - - - - -

    2D Platform Controller

    $Screen Shot 2013-07-23 at 9.06.23 AM.png

    The 2D Platform Controller is a character controller for 2D and 2.5D platform games. It is an alternative to physics based or character controller based controllers. Check out some of the features in the videos below.

    Play The Demo
    Or the Better Looking Demo


    Latest News: Crouching and Crouch Sliding has been submitted.


    Basics:
    [video=youtube_share;utpLu2gm8cs]


    With 2D Toolkit


    Ledges:
    [video=youtube_share;UtWOFyY2lco]


    And heaps more on the youtube channel above.

    Support

    Getting the settings tweaked to fit your needs can take some time, if you are having trouble contact me here or support at jnamobile.com

    Feature List

    - Works with any colliders including mesh colliders.
    - Handles sloped platforms.
    - Simple model for adding your own platform types. Sample include moving platforms, ice, and conveyer belts.
    - Double Jump, Wall Jump
    - Event based animation with 2D and 3D samples.
    - Many parameters to control how your character "feels".
    - Works on mobile.
    - Simple but effective mobile touch controller included.
    - Full source so you can adapt as needed.
    - Easy support for mutable hitboxes (e.g. characters who change shape, or can duck).
    - Pass through platforms.
    - Climbable ladders and areas (vines, etc).
    - Ledge hanging and climbing.
    - Wall sliding.
    - Crouching and crouch sliding.
    - Samples for enemy AI, fall damage, projectiles, etc.


    Version Support


    Supports Unity 3.5.7 and Unity 4.x.
     
    Last edited: Aug 27, 2015
  2. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    I can't wait to use it... for Unity 3.5 !
    Hope it is very soon on the asset store !!!

    Question : You place the "colliders" manually near to the character when it has a "stop" sprite !
    What happens when he has a walk animation for example with these colliders !?! Do they adapt to the size of the sprite ?
    (Hope you understand my bad english !?!)

    6R
     
  3. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Generally its best to place the colliders near the edges of the walk frame. From what I can gather this is what most games do (mario, sonic, etc). There is no attempt to detect pixels automatically.

    However you can also attach colliders to an arbitrary transform if you wish to move them about. For example you could attach them to a bone in a 3D model. Or in the case of a pixel based sprite you could add a transform which you move through code in sync with your animation.

    In my experience this is rarely needed; it is primarily provided for when you have characters who can duck (transform the head colliders downwards), or when you have a character whose size changes significantly when for example they gain a new weapon or ability.
     
  4. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    To those that have purchased please feel free to ask questions, request updates, etc.

    If you like it leave a review, if not allow me to address your concerns!
     
  5. EvilNoodle

    EvilNoodle

    Joined:
    Nov 17, 2011
    Posts:
    27
    Picked this up after watching the videos.

    Not had a chance to play with it yet but it has certainly inspired me to dig out and re-vamp my 2D tile creation workflow. Feeling like making a simple platformer now!

    EvilNoodle
     
  6. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,611
    I'll be buying this soon; looks perfect for what I need! Just in time :). Will save me countless hours it looks like.
     
  7. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Thanks guys. I hope it does save you countless hours!

    If you have any issues please PM/post or email me... I'm eager to help :)
     
  8. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    how your plugin works on iOS?
     
  9. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    I mostly do iOS development so its pretty good. You need to be a little bit mindful of the number of colliders. For example I wouldn't use it for enemies if it is not needed. An enemy which patrols a platform has no need of a complex controller.

    The default sloped character prefab has 12 colliders and takes about 2.5ms of processor time on iPhone 4S with all features turned on. As long as you are a little careful with your level design you can get away with less colliders even with slopes. Without slopes you can go down to 8 or even 7.

    You can also turn off features to improve performance.

    Finally you can manually edit the code (with my help if needed) to turn off some of the internal features which can again help performance. This is probably not needed, but its always an option to eek out a little more performance.

    I have a version of this running in a beat-em up like game that runs on 3GS with 6 onscreen characters. The game also has hitboxes, etc, but is pretty rocksolid at 30 fps. On a 4 or above its solid at 60fps.
     
  10. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    thanks for the reply.
    there is an example touch (button) control?
     
  11. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Hi JohnnyA,

    just bought it . Great.

    I'm a bit confuse for using Animation with 2 scripts : ModelAnimator and SptriteAnimator . Can you give some examples for using these sripts ?

    Thanks
     
  12. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    There is in a way... I accidentally left one in there that I was using to test iPhone performance :(.

    Its okay for testing but wouldn't really be suitable for a game. Although its pretty easy to add your own controls I plan on writing an nicer one for the next release.

    I'll also add my PS3 and 360 controls.
     
    Last edited: Mar 13, 2013
  13. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Hi Sefou,

    the idea is that it can work with any kind of animation framework. I figure for 2D a lot of people will use lots of different packages. I've included two samples to help people get an idea, and over time I will certainly add more.

    Model Animator - This works with Unity Legacy Animations (i.e. the ones before Mecanim). Its for 3D models. If you place this script on a model which has Legacy animations named "run", "walk", etc, it will animate the 3D model. You can see it in use in the sample video.

    Sprite Animator - On the Unity Wiki there is a free 2D sprite manager called Sprite Manager 1 (link in the script). This script works with that. It requires a sprite sheet and allows you to specify the position of the various animations in the sprite sheet. Although SM1 is free, I can't include its code in my package without permission so in order to avoid compilation errors the Sprite Animator code is commented out. To use this script install SM1 from the wiki, and then uncomment out the code. You will also need to go through and indicate where your animations are.​

    As mentioned I'll be adding more over time. I think Smooth Moves will be first as it has been requested the most (and will be really simple as its pretty much the same as Legacy Animation). Other things I expect to add over time are Mecanim, Ex2D, 2D Toolkit and SM2.

    EDIT: I'll add some videos of how to set up animations.
     
    Last edited: Mar 13, 2013
  14. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    464
    When do you think than SmothMoves update will be released?
     
  15. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Its number 2 release on my list so probably a few weeks.

    I don't have SmoothMoves as yet... but the code should be basically as follows:

    Code (csharp):
    1.  
    2. public class SmoothMovesAnimator : MonoBehaviour {
    3.    
    4.     public RaycastCharacterController controller;
    5.     public SmoothMoves.BoneAnimation boneAnimation;
    6.  
    7.     void Start(){
    8.         // Register listeners
    9.         controller.Idle += new RaycastCharacterController.CharacterControllerEventDelegate (Idle);
    10.         controller.Walk += new RaycastCharacterController.CharacterControllerEventDelegate (Walk);
    11.         // And so on for each animation
    12.     }
    13.    
    14.     public void Idle (CharacterState previousState) {
    15.         boneAnimation.Play("Idle");
    16.         CheckDirection();
    17.     }
    18.  
    19.     public void Walk (CharacterState previousState) {
    20.         boneAnimation.Play("Walk");
    21.         CheckDirection();
    22.     }
    23.  
    24.     // And so on for each animation
    25.  
    26.     // Implementation here depends on how smooth moves handles turning around ... does it use rotation, or scale, or something else
    27.     private void CheckDirection(){
    28.         if (controller.Velocity.x > 0 ) {
    29.             transform.localRotation = Quaternion.Euler (0.0f, 270.0f, 0.0f);
    30.         } else if (controller.Velocity.x < 0) {
    31.             transform.localRotation = Quaternion.Euler (0.0f, 90.0f, 0.0f);
    32.         }  
    33.     }
    34. }
    35.  
    It is very similar to the legacy animation animator (ModelAnimator.cs).
     
  16. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    ok I'm waiting for the next release
    thanks
     
  17. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    No probs. Just a note you can use it with the standard sidescroller mobile controller (from Unity) pretty easily.

    I just wrote this script which does so, works perfect:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class StandardMobileInput : RaycastCharacterInput {
    6.  
    7.     public Joystick right;
    8.     public Joystick left;
    9.    
    10.     private int tapCount;
    11.    
    12.     void Update ()
    13.     {
    14.         jumpButtonDown = false; jumpButtonHeld = false;
    15.         if (tapCount == right.tapCount  tapCount > 0) jumpButtonHeld = true;
    16.         else if (right.tapCount > tapCount) jumpButtonDown = true;
    17.         tapCount = right.tapCount;
    18.        
    19.         // This allows for analogue input ... you could clamp it if you just want 1 and -1
    20.         x = left.position.x;
    21.         y = left.position.y;
    22.        
    23.     }
    24. }
    25.  
    Steps:

    1. Import standard mobile assets
    2. Drop Unity's "2D Side Scroller" asset into the scene.
    3. Remove the child called "2D Side Scroller" from the prefab and leave the two touch inputs.
    4. Copy Joystick.js into a folder called Plugins.
    5. Create script above and attach to your character.
    6. Assign the right and left controllers to the input.
    7. Assign the input to the character.

    A few steps but it took me 3 minutes... and that included writing the script :)
     
    Last edited: Mar 13, 2013
  18. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Hi JohnnyA,

    Thanks for your quick answers. ;)
     
  19. sirius_002

    sirius_002

    Joined:
    Aug 16, 2012
    Posts:
    65
    Bought this yesterday and it seems like a good alternative to other, more bloated controllers on the asset store. If JNAmobile keeps supporting and adding new features to this package it can definitely be one of the front runners in its genre. The price doesn't hurt either!
     
    Last edited: Oct 15, 2013
  20. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    No problems ... I will need to go to sleep in a few hours so I'm getting as many answers in before I do so.
     
  21. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Hey Johnny, just a 'thinking out loud' question. How difficult would it be to pull off a ski or snowboard type game with your platform? Primarily, the slide n jump type stuff? This may not be a great fit as it likely would require the ability to AddForces to speed up and get a good jump. Just curious what your thoughts are.

    thanks,
     
  22. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    464
    Thank you for your quick answer.
    I will wait for your update ;)
     
  23. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    There's already platforms that can add force. However the main issue is that platform movement is always treated as horizontal movement (even on a slope). I'm thinking each platform you could have an attribute which adds vertical force based on horizontal speed but I'm not sure how accurate it would look.

    If you were building platform game which has some ski like elements it might work out okay. If you were building a ski game which had some platform like elements you are probably better off with a more physically accurate solution.
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Next release will be submitted shortly. Includes:

    • 3.5.x support.
    • Improvement to ladder functionality.
    • Sample mobile project using Unity's touch controller.
     
  25. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Great ; Ladder Top (Step1 with Top Step Platform script removed) , when the character go to 1 , he falls down directly to 2 .
    Is there a way to let him go down smoothly ?
    Thanks.

     
  26. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Can you explain the desired behaviour in a different way. If top step is removed, character should be able to climb down the ladder, but will "bobble" around the top.

    Do you want the character to fall down the ladder... but slower than normally?
     
    Last edited: Mar 15, 2013
  27. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    in this case , the weird thing is character fall down quickly to the ground instead of climbing down smoothly the ladder .

    I simply want the character climbing down slower and in ladder bottom character can stay hanging it , something like this.

    $img 2.png
     
    Last edited: Mar 15, 2013
  28. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    499
    This looks really good. Any issues mapping your movement to cInput2?
     
  29. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    If you remove top step script and also have autostick=false then the character wont "know" its on a ladder until you tell it by pressing up and down.

    If you set autostick true it might give you what you are after?

    Why did you need to remove the top step script?

    Might be better to take this to PM, you can send me your sample if you like.
     
    Last edited: Mar 15, 2013
  30. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Input is provided by any class implementing a simple abstract class that maps x axis, y axis, and the jump button. You should be able to map any kind of input in a few lines.
     
  31. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    OK ,
    i remove Top Step Platform script , Auto Stick true ; touch with key Space , character work perfectly .

    Thanks.
     
  32. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    Hi JohnnyA. very good news.
     
  33. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    :) I'll PM you when its approved.
     
  34. blaize

    blaize

    Joined:
    Jul 25, 2012
    Posts:
    41
    Just bought the kit, and it's looking great!
    For the upcoming version, could you also include a simple 3d animated character like you've shown in the video?
    i think it would be a great way to not only get people up and running very fast, but also show the versatility of this kit.

    Looking forward to the upcoming update! :D
     
  35. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Hi blaize,

    thanks for the purchase.

    Creating more sample scenes is definitely on the agenda. I'll definitely look in to getting a 3D character, I have plenty of 3D characters but they are all licensed in such a way that they can't be distributed. *Heads over to OpenGameArt.org *

    As for the update just testing it out now before submission. Need to make sure the ladder updates haven't impacted mobile performance.

    - John A
     
  36. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    499
    Purchased and this is awesome. I had been struggling with my own 2D platform implementation and this was a bargain for how easy it was to setup. The raycast setup is amazing though if I had to add a small interface tweak it would be nice for a checkbox to lock them to Z zero so you could move them around without needing to zero them out when you're done tweaking. Collision is for the most part perfect but on high speed falls occasionally I do miss the ground collision. My solution was to add an extra ground cast just behind the 3 feet and it seems to fix it.
     
    Last edited: Mar 16, 2013
  37. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    In order to avoid falling through the ground ensure that: Terminal Velocity * maxFrameTime < feetCollider.distance.

    The update has comments and doco to explain this better, as well as values that prevent falling through the ground (maxFrameTime was a bit high in the sample scene in v1.0.2... silly me rushing the product out).

    As a baseline I suggest terminal velocity 12, maxFrameTime 0.04f, and make the feetColliders 0.5f long.

    ----

    As for the editors, definitely something that I plan to work on. I tend to enter values manually most of the time, and the editor was a new addition. Locking to Z = 0 is a great idea, I always work in ISO so I never in realised they could move in Z :s
     
    Last edited: Mar 16, 2013
  38. parnell

    parnell

    Joined:
    Jan 14, 2009
    Posts:
    206
    Hi JohnnyA,
    I've been slammed with moving (Boston to San Francisco) but I'm dying to buy and work with this product.
    You mentioned needing a character. I should have some kind of biped lying around on my hard drive (I'm a character artist professionally)
    However, since I'm moving it'll take me a little while to track one down. Also, it wouldn't have animations besides run, walk, soooo perhaps you are better looking over on Opengamearts.org. lol

    What options are you thinking of adding next? I'd love to see a simple AI.
    Great work can't wait to buy this product, but first I need to lock down an place to rent (not easy) and then moved and unpacked!
    Thanks again for a great product and fast responses.
    B
     
  39. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Hi,
    project Pinocchio , character , fbx format, rigged and full compatible with Unity, is free for commercial use:

    http://projectpinocchio.autodesk.com/
     
  40. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    Thanks for the ideas.

    For the people that asked ... performance numbers are now in first post.
     
  41. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,237
    Thinking about purchasing this, looks great!
    Do you think about PlayMaker-Support?
    An Uni2D-Support would be also great!


    Edit:

    I am wondering. Does your plugin only work with Boxes? Or can i use Capsules, Spheres etc.?
     
    Last edited: Mar 16, 2013
  42. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    All colliders including mesh colliders. As an example about midway through the first video there is a capsule collider added to the scene.
     
  43. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,237
    Great!

    So about my other questions?

    PlayMaker and Uni2D - Support?
     
  44. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    I do plan to add more frameworks over time and I will add Uni2D and PlayMaker to the list. That said integrating with 2d/animation (like Uni2D) frameworks is usually pretty simple. Copy one of the existing classes and substitute whatever call is required to trigger an animation.
     
  45. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    499
    For anyone who is curious I'm already using it with smooth moves and it works great. I'm actually not sure how support could be improved in the update.
     
  46. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,237
    Great! I am buying this when the 3.5.X Update will be online :)
     
  47. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,990
    I'm just adding some more platform types (mario like bricks), and creating a mobile sample scene. Once thats done I will submit new update (which will be 3.5.x. compatible). Of course Unity will probably take a week to approve :s
     
  48. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,237
    I am really looking forward to that, it looks like the perfect solution for my team; we are currently working on a Platformer-Game and i struggled on a good Platforming-Controller, and it appears your Controller is a real neat way to handle that stuff. Glad you showd up with it :D

    That said, i must admit i am a heavy PlayMaker-User, but not afraid of Coding. Would be really nice if there were rather sooner than later some, at least, basic PM-Actions (Moving/Jumping).
     
  49. msbranin

    msbranin

    Joined:
    Jan 19, 2009
    Posts:
    104
    has anyone managed to create an animator script for 2D Toolkit yet?
     
  50. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    +1 for Uni2D support...
    6R
     
unityunity