Search Unity

[Released] 2D Platform Controller

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

  1. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Okay this weekends plan... ropes for Platformer PRO, this is probably the last complex core behaviours things left to do.
     
  2. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    Tried re-evaluating this package again, looks like the double jump bug I found last time I used the package is still there:
    http://forum.unity3d.com/threads/17...oller/page53?p=1400308&viewfull=1#post1400308

    The issue is present in both character controllers and is easily fixed by changing this:
    Code (csharp):
    1.  
    2. } else if (jumpCount == 1  jump.canDoubleJump  !IsSwimming) {
    3.     Unparent ();
    4.     startedClimbing = false;
    5.     jumpCount++;
    6.  
    to this:
    Code (csharp):
    1.  
    2. } else if (jumpCount < 2  jump.canDoubleJump  !IsSwimming) {
    3.     Unparent ();
    4.     startedClimbing = false;
    5.     //Use up ground jump if in air
    6.     if (jumpCount == 0)
    7.         jumpCount++;
    8.     jumpCount++;
    9.  
    2) The down + jump passthrough action seems very unresponsive, sometimes when I hit down+jump the character doesn't go through, any way to make it more forgiving so multiple attempts aren't required?

    3) With the #1 issue being months old, do you have an issue tracker we could submit to? Going through megathreads like this make it easy to miss things, and we've only got human memories :p

    4) This is more of a feel thing, but I think it should be in by default, it's an airspeed limiter that occurs when the jump button is released, it's in most retro platformers to give you more control over your jump height:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(RaycastCharacterController2D))]
    5. [RequireComponent(typeof(RaycastCharacterInput))]
    6. public class AirSpeedLimiter : MonoBehaviour {
    7.     RaycastCharacterController2D controller;
    8.     RaycastCharacterInput input;
    9.  
    10.     public float jumpSpeedButtonReleasedLimit = 6f;
    11.  
    12.     void Start () {
    13.         controller = GetComponent<RaycastCharacterController2D>();
    14.         input = GetComponent<RaycastCharacterInput>();
    15.     }
    16.    
    17.     void Update () {
    18.         if(!input.jumpButtonHeld  controller.Velocity.y > jumpSpeedButtonReleasedLimit)
    19.         {
    20.             controller.Velocity = new Vector2(controller.Velocity.x, jumpSpeedButtonReleasedLimit);
    21.         }
    22.     }
    23. }
    24.  
    (I know JumpHeldTime can do something similar but I find that to have an elevator like feel to it which I find inoptimal)

    5) Not sure if this is already addressed but in the HeroSample2D grabbing the moving platform acts very strangely
     
  3. Xevoius

    Xevoius

    Joined:
    Sep 26, 2012
    Posts:
    25
    Thanks for sharing stuff like this eedok. I am going to eventually go back and try and polish up my jump behavior.
     
  4. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hi eedok, I have been building the new Platfromer PRO not updating the old 2DPC but its taking a long time to come together. Although I have spoken about doing a 2DPC bug fix version at this stage I'm just responding to peoples individual requests via the support channels. It is rare for a request to go unanswered for more than a day or two so people seem to be happy enough to work this way while I get Platformer PRO out the door.

    I couldn't get the issue with passthrough jump+down to repeat in a quick test, which sample are you using when you experience this?

    - John A

    PS In case you aren't aware I'm rebuilding 2DPC and renaming it Platformer PRO. The new build has extensible/pluggable movement system from the ground up, is more robust, includes melee/ranged/enemies etc as core features, and is much easier to use. Theres a bunch about it on the youtube channel: https://www.youtube.com/user/JNAMobileHidden
     
    Last edited: May 9, 2014
  5. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    It's happening in AlienSample2D, seems to be more apparent when you move the platforms closer together like this:


    EDIT: also in my point 5 I figured out why it's happening, seems the 2D controller doesn't have any of the ParentOnStand code implemented
     
    Last edited: May 10, 2014
  6. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I'll check it out. Regarding the 2D physics version, it certainly has some of the parent on stand stuff implemented:

    Code (csharp):
    1.  
    2. // Check for parent
    3. Platform2D platform = ledgeHangCollider.gameObject.GetComponent<Platform2D> ();
    4. if (platform != null) {
    5.     Transform parentPlatform = platform.ParentOnStand (this);
    6.     if (parentPlatform != null) {
    7.         myParent = platform;
    8.         if (myTransform.parent != parentPlatform) {
    9.             myTransform.parent = parentPlatform;
    10.                         ...
    11.  
    BUT there's no reason to use the 2D version unless you are migrating a game that already has all the levels built with 2D colliders (and even then consider migrating).

    It was originally added because the plan was to move 2DPC to 2D, but now the plan is to rebuild its really of no consequence. Use the 3D physics version.

    For those who aren't clear: of course you can use 2D sprites, I'm talking about the 2D colliders.
     
    Last edited: May 10, 2014
  7. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Hi Johnny, im thinking of switching all my main character animation system to mecanim, im actually pretty advanced on my prototype in version 1.8 with all my animations in legacy mode (im doing a 2.5D), do you think i should wait to platformer PRO release, or maybe the beta version or try the "demo" of 1.9? are 2DPC and PRO "compatible" in some way or everything is going trough a mayor overhaul?
    As always, Thanks for this amazing system.
     
  8. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    They are not compatible so I wouldn't wait. I mean basic geometry and stuff will move of course, but there's no code or data structures in common.

    - John A
     
  9. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    k re-re-evaluating with 3D physics, already noticed something when switching, seems drop through platforms in the non-2D version don't react the same way as the 2D ones, as you always go through them when holding down instead of them watching the dropFromPlatform field in the input, fixed by changing the
    Code (csharp):
    1. character.characterInput.y < 0.0f
    to
    Code (csharp):
    1. character.characterInput.dropFromPlatform
     
  10. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    On that, I think dropFromPlatform = true should probably be set when jump button is held as well as the frame it is pressed.
     
  11. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    Is there a way to allow slopes without rotating the player? (Making the slopes Castlevania style stairs makes the character look tipsy)

    Changing the rotation speed of slopes to 0 makes them get caught up on the beginning and end of slopes
     
  12. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    The controller itself must rotate but there's no reason the sprite has to. Attach a script so that the sprite doesn't rotate (one liner in Update to reset the rotation). This is native in PRO (https://www.youtube.com/watch?v=D6nQRv3rIpA#t=45) but pretty simple to add to 2DPC .
     
  13. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    k almost got my evaluation scene the way I want it, just having an issue getting stuck in walls when falling downwards, any idea what could cause it?


    Here's what the raycasts look like when it happens:


    EDIT: suspected the wall was too thin, so tripled the width of the wall, still happens but like this instead:


    EDIT2: Figured it out, accidentally turned on ledge hanging
     
    Last edited: May 10, 2014
  14. jcdenton2030

    jcdenton2030

    Joined:
    May 4, 2014
    Posts:
    4
    JNA - love the controller. Have a question - and it is a bit beginner.

    2d platformer under development, while I learn unity. I wanted, desperately to use the ledge grab you have in the 3d example, but in 2d. Was thinking to develop ledge grab, and mantling around. Any examples, or thoughts on how to develop ledge grab / mantle mechaincs in your 2d example?

    Any thoughts would be welcome
    Cheers mate
    JCD
     
  15. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    The ledge climb works with a sprite you just need to set up the sprite correctly, primarily by making sure the character rotates around the hand when the character climbs the ledge. I have an example set up somewhere will try to find it.
     
  16. mousse

    mousse

    Joined:
    Oct 3, 2013
    Posts:
    27
    Hows 2.1 preview progressing? /annoyingpoke

    Again, thanks for all your hard work!
     
  17. The_Daleatron

    The_Daleatron

    Joined:
    Nov 26, 2013
    Posts:
    43
    Havent checked in for a while, any updates ? I might fancy a shot with the un released version how do i get a copy of it ?
     
  18. GadoBelial

    GadoBelial

    Joined:
    Feb 22, 2014
    Posts:
    9
    jcdenton2030 :

    For the climbin effect in 2d.

    As u can see, when the character is climbing something, it runs a "climb" animation, and at the end, it relocates the player on a position over the platform it was climbing.
    To create the same effect on a 2d sprite i modify the center of the sprites on certain frames to make it look like is moving.

    Let me explain it with an image :p


    $climb.png

    [Edit]
    Well i forgot to put it on the image, but i move the position in x of the sprite center too, to give it a better look when climbing. :p
     
    Last edited: May 14, 2014
  19. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    To all:

    I will no longer be replying to requests in forums. Please send all requests to the support address in your products documentation. Be sure to include your asset store order number and a detailed description of your issue or request.

    Regards,

    John A
     
    Last edited: May 20, 2014
  20. jcdenton2030

    jcdenton2030

    Joined:
    May 4, 2014
    Posts:
    4
    @GadoBelial - sweet, many thanks. Will work on it tonight.
    Cheers
     
  21. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    To all:

    I will no longer be replying to requests in forums. Please send all requests to the support address in your products documentation. Be sure to include your asset store order number and a detailed description of your issue or request.

    Regards,

    John A
     
    Last edited: May 20, 2014
  22. GadoBelial

    GadoBelial

    Joined:
    Feb 22, 2014
    Posts:
    9
  23. KidSicarus

    KidSicarus

    Joined:
    Feb 3, 2014
    Posts:
    35
    Hey, Johnny.

    I hope you don't hate us all and you're just diverting your attention to Platformer PRO.

    We're counting on you and trust your decision.

    Thanks for your efforts!
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Just aiming to optimise my time so I can try and catch up on the some of these updates. It's really hard to track support requests that come via forums.

    - - - - -

    ALSO - Anyone who has a completed game, or nice prototype (like that from GadoBelial above) if you would like to create a small video snippet I'm creating a promo video to add to my channel. Some notes

    - Video should be be 10-15 seconds long
    - You can include your logo/company name/etc (I will also add a clickable link to a web address of your choosing)
    - Sound may be removed at my discretion (I'll probably have some backing music for consistency)
    - Be at 1,280 x 720 (720p)
    - Be reasonably pretty :)

    I'll be I'll be compiling together then posting on my youtube channel (which gets reasonable amount of hits), and I may pay some cash to get the video promoted.

    To submit your video send a support request with 'video' in the title and a link to a download.

    Regards,

    John A
     
    Last edited: May 21, 2014
  25. GadoBelial

    GadoBelial

    Joined:
    Feb 22, 2014
    Posts:
    9

    Working on it, just let me finish some more sprites to make it prettier :D
     
  26. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Hi Johnny, im working on a sample video, how much time do we have to submit it?
     
  27. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    A few weeks at least.
     
  28. The_Daleatron

    The_Daleatron

    Joined:
    Nov 26, 2013
    Posts:
    43
    I dont suppose you would consider adding a 2d platform controller forum to your website, so people can share tweaks and help each other out with the questions etc
     
  29. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Sounds like a good idea, I'll see if the support software can handle community knowledge base. If not then drupal can surely support a forum.
     
  30. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Hi Guys, i know Johnny is a little busy lately, but maybe someone can help me, im an artist learning to code, have patience with me :).
    I want to implement a "jump offset" from platforms, what i want to do is that if a player is walking/running at X or more speed and reach the limit of a platform, he have like 100 or 200 milliseconds more to jump. Super Mario bros do this, you can jump at the very ledge of platform and sometimes it feels like its jumping in the air, i would like to implement something like this to make jumping a little easy in my game when you are running like crazy.

    Anyone have any idea how to do it? (im thinking of some kind of timer after "isgrounded" is false, but i dont want to mess directly with the controller).

    Here's an illustrated example of what i want:


    Thanks!
     
  31. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I'm busy but you can always send a support request. I check these at least once a day! I implemented this in Platformer Pro as a timer pretty much as you described. But It might be a bit hard to do it without touching the main code. If you add your timer you should only need to adjust the if statement around the jump code to check your timer or isGrounded instead of just isGrounded.
     
  32. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hrm new forum making it a bit hard to track things at the moment.
     
  33. Vidd

    Vidd

    Joined:
    Jun 3, 2013
    Posts:
    7
    Quick question for anyone familiar with this asset - is it easy enough to set up for steps?
    i.e. A series of platforms where each one is slightly higher and the character raises onto the next one, rather than getting stuck.

    I assume it works well with 2D Toolkit which I already own, too.
     
  34. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Steps are not catered for. If you are doing 3D animation then you can use IK foot placement + a slope to get step behaviour, its custom work but has been done before to good effect. For 2D it would be pure custom work, I expect you could send another raycast to find step height and then offset set your sprite position.

    2D toolkit is supported but since Unity 2D has been released I haven't actively followed 2DTK updates. That said the integration is pretty straight forward, no one has reported any issues and if there are I'm happy to support/fix.
     
  35. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Platformer PRO update (power ups):

     
  36. Mike_011972

    Mike_011972

    Joined:
    Jun 8, 2009
    Posts:
    97
    Hello,
    Had 2D platform controller for a while now, but only just started to use it (really great fun by the way).
    I'm trying to do a one way platform that will let you drop down, through it, but not be able to jump up through it.
    My initial idea is just to disable the box collider for a set time when the player presses down, but is there a better way as that could have a knock on affect? Also, just learning scripting, so the simple stuff can take me a while to code up.
    I've got platforms that will allow one way going up and platforms that allow passage through it, both up and down, just need to work out a clean way of doing pass down only platforms.

    Also, this is aimed at Johny, when will the new platform kit be available and if we bought from you, is it possible to get a key for the Unity Store version when it's available (like steam keys)? Would love to try / buy the new version, but much prefer having all my plugin's from one place.

    Thanks in advance for any advice.
     
  37. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Disabling the box is probably the easiest way, and I think with a well set timer and sensible placement it should be issue free. Beyond that you would need to edit the controller such that the head colliders collide with an object but the feet/sides don't. Setting up different layer masks for feet and head is not overly difficult.

    The new kit will replace the current one. So you will get it automatically. I may release a LITE version before I release the main version. In this case you wont get the LITE version free from the store, but you can request it from me and I'll send it on.
     
  38. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
  39. Mike_011972

    Mike_011972

    Joined:
    Jun 8, 2009
    Posts:
    97
    Excellent, I'll give the disabling collider idea a go first.
    Thanks for the reply.
     
  40. Xevoius

    Xevoius

    Joined:
    Sep 26, 2012
    Posts:
    25
    I am working on getting my player to swim. Has anyone else gotten this to work cleanly? I tried running the sample scene and the player just sinks.

    So as of right now, my player jumps into the water, the collision is identified and I manually set the isSwimming flag. The player falls with the same gravity as a normal jump until he hits the bottom and then all the swimming traits turn on like the overridden water gravity and the water resistance however I am unable to get the player to perform a swim stroke.

    Anyone have troubleshooting suggestions for me?

    Thanks.
     
  41. Xevoius

    Xevoius

    Joined:
    Sep 26, 2012
    Posts:
    25
    Nevermind. I just implemented a workable solution for a swimming stroke which ended up a variant of my bounce platform solution. Here is a little snippet for how I got the stroke to work just to share.

    Code (CSharp):
    1. void FixedUpdate()
    2. {
    3.     // Handle a Swim Stroke
    4.     if (Input.GetKey(KeyCode.Space) && ToolBox.playerController.raycastController.IsSwimming)
    5.             raycastController.Velocity = new Vector3(raycastController.Velocity.x, 5.0f);
    6. }
    He can also jump out of the water so I think I am good...I think :)
     
    Last edited: Jun 9, 2014
  42. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Wouldn't mind seeing your swimming setup if you can send it through... mine is overly complex :)
     
  43. Mike_011972

    Mike_011972

    Joined:
    Jun 8, 2009
    Posts:
    97
    Was able to spend sometime last night and got my oneway down platform working.
    Here's the code, just in case anyone else might find it useful (not the best of coder, but it works).

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. public class PassthroughDownPlatform : Platform {
    6.    
    7.     public float fallThroughTime = 1.0f;
    8.  
    9.     public bool requireJump;
    10.    
    11.     override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
    12.         if (character.FallThroughTimer <= 0.0f && collider.direction == RC_Direction.DOWN && character.characterInput.y < 0.0f && (!requireJump ||character.characterInput.jumpButtonDown)) {
    13.             gameObject.collider.enabled = false;
    14.             character.FallThroughTimer = fallThroughTime;
    15.             StartCoroutine (SolidAgain());
    16.             character.characterInput.CancelJump();
    17.             }  
    18.         }
    19.  
    20.  
    21.     public IEnumerator SolidAgain () {
    22.         yield return new WaitForSeconds(fallThroughTime);//Wait X amount of time
    23.         gameObject.collider.enabled = true; //Make Collider
    24.     }
    25.  
    26. }
    Cheers,
    Mike.
     
  44. someunityguy

    someunityguy

    Joined:
    Jun 28, 2011
    Posts:
    35
    Does the 2D Platform Controller work with a xbox360 game-pad ?
    specifically the simple demo ? as i need a jumping box to test levels long before a character ever becomes involved.
     
  45. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Not out of the box, although integration has been set up by lots of folks. If you send a mail to support@jnamobile.com I'll try to find you some sample code (or at least demonstrate the integration).
     
  46. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Thanks for the info Mike,
     
  47. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Is it possible to implement wind? A certain script which pushes the character back?
    I tried to tweak x-value of the characterInput, but since x is protected it doesn't work.

    Any problems if I switch it from protected to public?
     
  48. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I think it would be better to just modify velocity:

    character.Velocity = new Vector2(character.Velocity.x + windFactor * Time.deltaTime, character.Velocity.y);
     
  49. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Aye! Way simpler to setup this way. Thanks!
     
  50. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    No worries.