Search Unity

[Released] 2D Platform Controller

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

  1. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    For the Uni2D Support i would say to wait till the Uni2D-Team brings out the new V2.0-Update (which will take about 1-2 weeks), there are a lot of "under the hood"-Changes which aren't compatible to the 1.0-Version, so it wouldn't make any sense making the Support for the 1.0 Version.
     
  2. retrophil

    retrophil

    Joined:
    Mar 16, 2013
    Posts:
    46
    Bought this the other day. Love it. Which brings me to my noob question. How would I collect coins? I've tried things like OnTriggerEnter, but that only works for rigidbodies doesnt it? So I guess the whole point would be to raycast a hit? or something? Just a little direction with your controller thats all.
     
  3. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    You could write a coin like this

    Code (csharp):
    1.  
    2. public class Coin : Platform {
    3.   override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
    4.     Collect();
    5.   }
    6. }
    7.  
    However there's absolutely no problem using colliders/triggers on your character for things like this. In fact I tend to use them and save the raycast colliders for things that effect how the character moves. You can see an example of collider use in the second video.

    If you use a collider just make sure that the collider is in a different layer to the layers used by the controller. And that the collider layer does not interact with the platform controller layers:

    $Screen Shot 2013-03-18 at 7.49.43 AM.png
     
  4. retrophil

    retrophil

    Joined:
    Mar 16, 2013
    Posts:
    46
    Thank you so much!
     
  5. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    The Update is (finally) submitted. Includes 3.5.x support, a bunch of code comments, a fix to a ladder bug, and a few new platform types (bricks, mario style unbreakable bricks).

    The package structure is also a little different, be sure to backup your old project when upgrading!
     
  6. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Is there a way to get the 3.5.X Version without upgrading to Unity 4.0.1?
    It says i have to upgrade in the AssetStore...but i don't want to.
     
  7. retrophil

    retrophil

    Joined:
    Mar 16, 2013
    Posts:
    46
    Thats really cool JohnnyA, I have been trying to learn c# for the past 6 months. I've gone through over 100 hours of tutorials. But I feel that I'm learning more by just getting my hands dirty. So any help towards your scripts in understanding them is greatly welcomed instead of looking at you as a powerful wizard with a box of magic tricks :D
     
  8. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    +1 : For Unity 3.5.7 without upgrading 4.0.1 !
    6R
     
  9. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Thats what the newly submitted package allows, but it will probably take about a week to be approved.
     
  10. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Ah, now i get it. Allrighty then, then i'll have to wait. Thanks though!
     
  11. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I'll send you a PM when its approved :)
     
  12. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Well, this is what i call support! Great, thank you Johnny! :D

    Edit:

    So, what are you thinking about PlayMaker-Support / Uni2D? When could it be available?
     
  13. parnell

    parnell

    Joined:
    Jan 14, 2009
    Posts:
    206
    While I have playmaker, and enjoy using it. I'd rather see JohnnyA focus on fleshing out the controller with more features, and more into a kit. Like simple AI, and a simple range/melee combat system. I look at that other platformer kits on the store and they don't have this level of sophistication on the controller. However, they have AI, attacks, weapons, and inventory. Just wouldn't mind seeing this one get fleshed out to match the features they have. Then get all that to work with playmaker.:)
    Can't wait for my big move to be over so I can setup my workstation, buy this and use it!
    B
     
  14. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    What would be the best way to go about having an exterior force push the player character since we don't have a rigidbody (no easy addforce)? This would be for things like bouncing off an enemy with greater force than just the raycast stopping movement. I can just move the transform but I was curious if there was anything better suited to this setup.
     
  15. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Firstly update has been approved... 3.5.x users rejoice.

    You have access to the players Velocity ... here's a horizontal spring (both directions, you should be able to see where it could be made one direction):
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class SpringPlatform : Platform {
    6.    
    7.     public float force = -3.0f;
    8.    
    9.     private bool alreadyAdded;
    10.    
    11.     override protected void DoUpdate(){
    12.         alreadyAdded = false;  
    13.     }
    14.    
    15.     override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
    16.         if (!alreadyAdded  (collider.direction == RC_Direction.RIGHT || collider.direction == RC_Direction.LEFT)) {
    17.             character.Velocity =  new Vector2(character.Velocity.x * force, character.Velocity.y);
    18.                 alreadyAdded = true;
    19.         }
    20.     }
    21. }
    22.  
    If you wanted to do something like a fan... I'd use triggers and a box collider (like the pushable box video) to effect character.Velocity.
     
    Last edited: Mar 20, 2013
  16. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    It's definitely easier for me to add those sort of features as 1) I have variations of many of them in existing products and 2) I don't have to buy third party tools. In the end I guess it comes down to what people want the most.

    I'm also part way through my Adventure Game Kit which includes a pretty nice Inventory component (as well as complex item interactions, dialog, cutscenes, music, saving/loading, etc). Maybe the Inventory System can be pulled out for around $5-$10 and made to work with the Adventure Kit and the 2D Platform Controller.
     
  17. blaize

    blaize

    Joined:
    Jul 25, 2012
    Posts:
    41
    Wow.. if that adventure game kit can be made compatible with the 2d Platformer controller you would have a real jewel on your hands!
    providing artists basically every tool they need to make the project they would want.

    You should definitely make that update 4.0 ;) (if time permits it)
     
  18. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I just wanted to mention, that the new Update is out now and it works fine with Unity 3.5.X. Just bought it and tested it. Great Stuff, great stuff, can't wait for future Updates!

    Edit:

    I would like to see some more Samples with other Character-Objects (like a Caspsule/Sphere-Collider etc.) :)
     
    Last edited: Mar 20, 2013
  19. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Do you mean scenes in the package, or more samples on youtube?
     
  20. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Thanks for the tip on player velocity. Also I'd be in for an inventory addon to your kit. This asset is extremely well organized and cleanly coded so I'd be interested in anything else you put out.
     
  21. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Perfect update . ;)

    Thanks

    NB :

    +10 for future Inventory System and Adventure Game Kit.
     
    Last edited: Mar 21, 2013
  22. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    In the Package :)
     
  23. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Just bought it... Great !!!

    Any chance of having an horizontal moving platform with the character perfectly following the platform without being totally fixed on it ?

    6R
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Not quite sure what you mean by "without being totally fixed on it"?

    A horizontal platform will be identical code to up and down platform except the transform will be in X not Y.
     
  25. progpixel

    progpixel

    Joined:
    Oct 19, 2011
    Posts:
    2
    Just bought this package. So far it's working great and it's easy to integrate. Definitely saved me a good amount of programming time :)

    In case you haven't found this already (in the 3.5.7f6 package) there's a bug involving the wall jump. If you wall jump and mash the jump button, you'll continually jump. Setting wallJumpTimer to 0 upon activating the wall jump fixes it.

    Edit: Actually, another quick fix involving a held jump: After releasing the jump button and quickly pressing it again (double jump disabled), velocity will still be added, resulting in a sort of floating effect. I added this right around line 568 to fix it.
    Code (csharp):
    1. else { jumpHeldTimer = jump.jumpHeldTime; }
     
    Last edited: Mar 22, 2013
  26. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    How would be the best way to get projectiles collision for a 2D Shooter?
    Like in Konami's Contra:
    $contra-world-challenge-big_1344930316.jpg
    I'm buying right now. I stopped with gamedev for a while and this script is making me want to get back...
    Please, let's improve it!
     
  27. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Thanks for the info. Both wall jump and jump held were a pretty recent additions and haven't had much "break" testing. Fixes will be in the next update.
     
    Last edited: Mar 22, 2013
  28. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    My focus has been on getting the core controller component locked down (i.e. movement), and to provide something that can (with the right tweaking) handle any platform game. However it seems there is a lot of interest in more specific functionality.

    My concern is I don't want to be prescriptive... I'd prefer to say this is one way to do function X, as opposed to this is how you must do function X. That said more samples and "supporting scripts" are definitely on the cards. Stand by and I'll post a list of what I'm hoping to do next update.

    As to your specific problem, I'd definitely do that with normal colliders and triggers, reserve the raycast character colliders for character movement. As discusses a few posts ago in the context of collecting coins (see also second youtube video), you can add triggers or colliders to the character as long as you ensure they are on a layer that does not interacts with the RaycastCharacterController.
     
  29. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Yes, everybody will ask for something specific, but this will make the controller get a big list of features.
    I took a look at what it already have and is awesome! Tomorrow I will stop some hours to play around with it.

    Here is my requests for now:
    $request.png
    1: A "turning slide" that happens when you are running and turns to anoter direction. If it happens, the character will slide for some inches, depending of the speed. Something like a "spring" effect.
    2: A "slide", when you press a button (down), the character slides for a while, and stops, depending of the speed too.
    3: A kind of "rope", where the character grab from one of the sides. If it turn, it will get on the another side. Its something like the ladder, but with an axis that the character will follow, like it was in an rope.

    Everything is based on Super Mario Bros 1. Then, you can play it to see how it works.
    If something is out of your development scope, just tell. No worry!
    Or, if something is easy to do, just tell me.
     
  30. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Firstly you will be pleased to know that a mario-like sample is high on the agenda.

    In the mean time:

    1. This is possible to some extent just with settings. If you lower acceleration and lower drag you will get more slide. There's no animation event for this but you could detect the state by comparing input to speed in your animation class:

    Code (csharp):
    1.  if ((input.x > 0.0f  character.velocity.x < 0.0f) || (input.x < 0.0f  character.velocity.x > 0.0f) DoSlideTurnAnimation();
    You can further accentuate your slide by adjusting the input values (x input is a float) or drag based on the characters current velocity.

    2. In your CharacterInput adjust drag if the down button is pressed. You will need to add a reference to your CharacterController in order to change Drag.

    3. This one is not simple within the current framework, so I'll need to have a think about it!
     
    Last edited: Mar 22, 2013
  31. sefou

    sefou

    Joined:
    Aug 30, 2011
    Posts:
    287
    Hi JohnnyA,
    is there a way to make SpriteAnimator.cs more "generic "? i try using this script with uni2D and i 'm stuck...

    Thanks
     
  32. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I think you should wait for the V2.0 Release of Uni2D, the Animation will be remade as far as i know, so it would be pointless to change the Script now.
     
  33. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Bit late here so excuse my quick reply ... use ModelAnimator as a baseline ... replace animation.Play() with equivalent function in Uni2D. SpriteAnimator has a bunch of unneeded stuff to make it work with SM1.

    - John A
     
  34. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Just bumping so it is above the old thread.
     
  35. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    A time ago I was planning to buy this asset:
    http://forum.unity3d.com/threads/90374-Released-2D-Jump-n-Run-Framework

    But now, I decided to buy yours. I think that the way you made it is awesome and Samb88 said that will stop adding new features to it.
    Then, you could put in your list:
    A model character with Smooth Moves and one in Sprites;
    Glide action;
    Wallslide action;
    Xbox360 controller integration;
    A simple enemy moving controller;

    I know that if I want this, I may buy the Samb's Asset. But I liked very much your framework, and I think that this features are awesome to your business.
     
  36. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hi Blaze my main focus is on getting a rock solid controller. However its nice to have additional features available, and I'll probably be doing this by adding sample scenes of various set-ups.

    As to your list they are all on the agenda*. I have some time this weekend and will probably focus on putting out a playable demo which will be included in the pack and which I can also host on the web.

    *I don't think I can include a smooth moves character without including smooth moves so I'm not sure what to do there.
     
  37. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    If I'm not wrong, Smooth Moves have a DLL that can be shared, just to run the animations, without the editor. I will check this with Echo17.
    I have Smooth Moves, if you don't have, and aren't with hurry, I can make the animation. And export to you the animations.
    Just tell me, if you want. But remember, you need to be patient. :)

    If you believe in me, I will tell that one month ago I was planning to do a "Super Mario Engine" when I come back to gamedev studies.
    Because of this, I bought your asset and want you to do it a complete solution. :)
     
  38. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Ahh I didn't know that. If thats the case then that sounds like a good idea.

    Also... found some pretty cool public domain sprites. Putting together a demo right now!
     
  39. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    EDIT: New package submitted.

    - - - -
    Argh just found a bug with horinzontal moving platforms. Fixes will be submitted soon. In the meantime:

    In the mean time there are a few things you need to do to get horizontal moving platforms:

    1) Make sure your moving platform returns true to ParentOnStand.
    2) Make sure it has velocity.x set to whatever direction it needs to go in.
    3) Fix the bug in RaycastCharacterController.cs:


    After this:
    Code (csharp):
    1.  
    2.   private void MoveInXDirection(bool grounded) {
    3.  
    Add this:
    Code (csharp):
    1.  
    2.   if (myParent != null) myTransform.Translate(myParent.velocity.x * frameTime, 0.0f, 0.0f);
    3.  
    - - - -

    Sorry for the bugs guys, I'll submit the next update shortly to ensure these are addressed.
     
    Last edited: Mar 24, 2013
  40. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Happy to see you added horizontal moving platforms...

    Thanks,
    6R
     
  41. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Yeah they have been in since I started messing with this thing ages ago... somewhere along the line I removed them accidentally :s
     
  42. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    BUMP, still awaiting approval.
     
  43. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Any news about the sprites demo?
     
  44. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I have the sprites but its taking a bit longer than expected because I decided to write my own sprite library. This was the only way I could see of ensuring it works without having to have a separate download.

    The library will be simple, but it still takes a bit of time.

    I guess the alternative is to follow up with SM1 developer and see if I can include that.
     
  45. parnell

    parnell

    Joined:
    Jan 14, 2009
    Posts:
    206
    Could you just make it so all those features played nice and release it as the Ultimate Kit?
    I mean I just checked your site and couldn't find a link to the Adventure Kit. Honestly, I'm fine paying more for everything if it's solid and well documented.

    Keep up the good work.
    B
     
  46. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422

    Does that mean your Controller is not compatible to other SpriteSolutions like 2D Toolkit or Uni2D ?
     
  47. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    This is sick work man, as soon as it's confirmed to play nice with 3.5 and 2D Toolkit you've got yourself another purchase.
     
  48. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    No! Where you read this? It means that he will make himself a embedded solution for sprites. Then you dont need to buy another Asset for simple sprites use.
     
  49. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Works very well in Unity 3.5.7.
     
  50. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Yeah, but i already bought other Assets months ago and like the workflow of them very much and don't want to miss them. I don't think i will use his Spritesolution (no offense here!), because i think the other ones (2D Toolkit, Smooth Moves, Uni2D etc.) are stable and have more features. Maybe i am wrong.

    I just want to use this Controller with another solution, without any problems, that's it :)