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
    Almost ready ... animated 3d model with LEDGE GRASP and CLIMB!

    [video=youtube_share;UtWOFyY2lco]http://youtu.be/UtWOFyY2lco

    @derkoi Ropes, really don't know what the issue could be, if you cant send the project maybe some screenshots of your colliders, properties, etc. Trampolines, certainly could be added. I've sent a sample platform class that does trampoline like behaviour to a few people, so I could clean it up and add.

    PS Video is still processing at the moment, give it a few minutes.
     
    Last edited: May 18, 2013
  2. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Absolutely fantastic !!!

    6R
     
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Great work!

    Can you make the character lean forward when he's walking up on a slope? and backward when he's walking down slowly and for ward when he's running down a slope, this will give a good appearance in the way the character moves
    The same when he's jumping. Or should tho she done in animation states triggered by speed and slope?
     
  4. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    great! I look forward to.
     
  5. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hi Lars,

    the main character needs to rotate to match the slope, so I think doing it in the animation controller makes the most sense. You could have the model as a child of the controller (recommended set-up) and rotate that directly OR have different animations for up-hill and down-hill and cross fade them. Let me know if you need some help with the setup.

    - John A
     
  6. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    When you jump in the slope, the rotate is looking weird, it seems that he is moved down the slope. This will be resolved?
     
  7. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    The animator hadn't centered the root of the animations so I expect thats whats making it look "weird". That has already been fixed.

    Although I want to be clear, I wouldn't expect these animations to be used by people beyond the prototyping phase.
     
  8. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Of course not, but the demonstration needs to show how it works nicely, dont agree?
    You cant take all by bad criticism, we are trying to get a good asset like you.


    The animation is looking great. It will be so easy to use Smooth Moves too!
     
  9. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I don't mind the criticism at all, as you say it improves the asset. But I do want to be clear that the purpose of the character, its to demonstrate the controller and provide a reference.

    Although that said, I know nothing about retargeting animations maybe people can reuse the hang and climb animations.
     
  10. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    So this is using mecanim and not legacy animations? If the animations are retargetable this is a huge boon to your asset and makes it even more unique on the store. Unity 4 animation retargetting is actually pretty simple and very useful. Looks great to me, can't wait.
     
  11. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Legacy at the moment, but also going to get them done for mecanim.
     
  12. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    So just to keep everyone updated:

    Release 1.5.0 - To be submitted May 31 or before

    Ledge Hanging/Climbing
    Animated Character with Legacy animations
    Price will be increased to $30.

    Other features which will likely make the 1.5.x cycle:

    Wall Slide
    2D Toolkit Sample Animator
    Better Ladders
     
  13. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Nothing really new here, just thought this was cute :)

    [video=youtube_share;YUYiB_Oysy0]http://youtu.be/YUYiB_Oysy0
     
  14. msbranin

    msbranin

    Joined:
    Jan 19, 2009
    Posts:
    104
    Here is an example 2D Toolkit animator

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class SpriteAnimator : MonoBehaviour {
    6.  
    7.     public RaycastCharacterController controller;
    8.     public tk2dAnimatedSprite playerSprite;
    9.    
    10.     void Start(){
    11.        
    12.         // Register listeners
    13.         controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate (CharacterAnimationEvent);
    14.     }
    15.    
    16.     /// <summary>
    17.     /// Respond to an animation event.
    18.     /// </summary>
    19.     /// <param name='state'>
    20.     /// State.
    21.     /// </param>
    22.     /// <param name='previousState'>
    23.     /// Previous state.
    24.     /// </param>
    25.     public void CharacterAnimationEvent (CharacterState state, CharacterState previousState) {
    26.         switch (state) {
    27.             case CharacterState.IDLE: Idle(); break;   
    28.             case CharacterState.WALKING: Walk(); break;
    29.             case CharacterState.RUNNING: Run(); break; 
    30.             case CharacterState.JUMPING: Jump(); break;
    31.             case CharacterState.FALLING: Fall(); break;
    32.             case CharacterState.DOUBLE_JUMPING: Jump(); break; 
    33.             case CharacterState.WALL_JUMPING: Jump(); break;   
    34.             case CharacterState.HOLDING: Hold(); break;
    35.             case CharacterState.CLIMBING: Climb(); break;  
    36.         }
    37.     }
    38.    
    39.     protected void Idle () {
    40.         playerSprite.Play("idle");
    41.         CheckDirection();
    42.     }
    43.    
    44.     protected void Walk () {
    45.         playerSprite.Play("walk");
    46.         CheckDirection();
    47.     }
    48.  
    49.     protected void Run () {
    50.         playerSprite.Play("run");
    51.         CheckDirection();
    52.     }
    53.  
    54.     protected void Jump() {
    55.         playerSprite.Play("jump");
    56.         CheckDirection();
    57.     }
    58.    
    59.     protected void Fall() {
    60.         playerSprite.Play("fall");
    61.         CheckDirection();
    62.     }
    63.    
    64.     protected void Hold() {
    65.         playerSprite.Play("hold");
    66.     }
    67.    
    68.     protected void Climb() {
    69.         playerSprite.Play("climb");
    70.     }
    71.        
    72.     protected void CheckDirection(){
    73.         if (controller.Velocity.x > 0 ) {
    74.             playerSprite.scale = new Vector3(1,1,1);
    75.         } else if (controller.Velocity.x < 0) {
    76.             playerSprite.scale = new Vector3(-1,1,1);
    77.         }  
    78.     }
    79. }
     
  15. msbranin

    msbranin

    Joined:
    Jan 19, 2009
    Posts:
    104
    Ok I have tried this and tried it and nothing seems to happen to my character when he collides with this platform
     
  16. zebualvi

    zebualvi

    Joined:
    Apr 14, 2013
    Posts:
    11
    Hey JohnnyA , is there any update planned to include health, health bar and fall damage? I am sure myself and many others here would really appreciate these.

    Thanks.
     
  17. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Things have changed a little since that was written, although it looks to be roughly okay.

    Maybe change the line: that sets velocitt to somwthing like:
    character.Velocity = new Vector2(collider.direction == RC_Direction.LEFT ? force, -1 * force, character.Velocity.y);


    I'll check it when I get some time later tonight.
     
  18. msbranin

    msbranin

    Joined:
    Jan 19, 2009
    Posts:
    104
    The code was actually right but.. When the player is running your holding the Move key down which forces the character to continually push up against the platform that is supposed to spring him away.

    If you move up to the pad and immediately let go of the move key it actually springs him away. So it kinda works.
     
  19. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Yeah, the way the movement works has changed since that was written, so I'll have to a come up with a new one. I'm thinking of adding a stun timer that will cause the character to ignore input while stunned. This would be helpful here, but also for lots of other things.
     
  20. Sensisensic

    Sensisensic

    Joined:
    Nov 24, 2012
    Posts:
    2
    Hi. I just purchased your package, which sounds a bit off, but either way, I love it and I have a quick question.

    Is there a way to make drag not a factor in the character's movement? I want to be able to stop movement instantaneously when I seize giving an input value. This you could accomplish by giving movement drag a high value, but then it starts impacting movement speed. Is there a more sound way to achieve this?

    EDIT
    Added a bit of a bandage solution, but it works for now.

    Code (csharp):
    1.  
    2. void KillMovementSlide (){
    3.         float hor = Input.GetAxis("Horizontal");
    4.         if (hor == 0){
    5.             movement.drag = 50;
    6.         }
    7.         else {
    8.             movement.drag = 10;
    9.         }  
    10.     }  
    11.  
     
    Last edited: May 25, 2013
  21. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I used to have "digital movement" in the controller but for some reason I removed it, will add it back sometime.

    In the meantime setting drag high and acceleration high tends to do the trick.
     
  22. blaize

    blaize

    Joined:
    Jul 25, 2012
    Posts:
    41
    When will you submit the 1.5.0 update? :)
     
  23. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Just waiting on some fixes for the new characters climbing and rope animations. If I dont get them by this weekend, I'll submit as is and add the additional animations later.

    - John A
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Didn't get all the fixes I wanted, but lots of them in. Just finishing documentation now, then will be submitting. Hopefully Unity will approve within a few days.

    Here's a demo that comes with the new package: http://jnamobile.com/samples/2DPlatformController/HeroSample.html

    PS Price will be rising to $30 with the new update.
     
  25. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    SUBMITTED

    Here's the next set of updates with a rough time frame.

    Item - Approximate Release Date
    More animations for 3D character - Early June
    Stun...Stop character movement/player input - Early June
    Wall Cling/Slide - June
    Fully Animated 2D Sample Character - July

    I'm also putting together a support forum which will include sample code for working with common packages like 2D Toolkit and SmoothMoves.
     
  26. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    a long time to wait when approve update
    can send on the invoice?
     
  27. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Yes send me an email or PM with your invoice number and I will send you the updated package
     
  28. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    ok send PM
     
  29. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Just bought your package today... (damn, that really does sound wrong), anyway Just had to say you seem like a terrific guy/vendor. The folks here seem to really enjoy your...err, asset and I look forward to jumping in as well.

    thanks,
    B.
     
  30. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hah first thing I read this morning, cracked me up. Lets call it the the package not my package shall we? Hope you enjoy playing with THE package.

    - - - -

    To everyone else, some more animations (plus clean up to existing ones) coming in 1.5.1 which ideally will be a week or so behind the 1.5.0 release.
     
  31. Banholio

    Banholio

    Joined:
    May 14, 2012
    Posts:
    3
    Hi johnny, I also requested the 1.5 version

    Thanks!
     
  32. Banholio

    Banholio

    Joined:
    May 14, 2012
    Posts:
    3
    BTW, Is there a way to create a rope (stiff) runtime with a certain angle and then attach the character to the tip of it ?

    I'm trying to make a throwable rope, I have already done everything but I cannot attach the character :(
     
  33. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Ohh, that sounds cool, but maybe a bit tricky. I've been thinking about a bionic command style swing rope, but to be honest its a few months away at very best. Here's a sketch of what you would need to do if you wanted to implement without changing the core code:

    To force the character to attach you need to:
    1) Ensure character is positioned at the right point.
    2) Rotate the character to the correct angle.
    3) Execute the rope steps parentOnStand method and assign the platform AND transform.

    Code (csharp):
    1.  
    2. Transform parentPlatform = yourRopeStep.ParentOnStand(this);
    3. if (parentPlatform != null) {
    4.   myParent = platform;
    5.   if (myTransform.parent != parentPlatform) {
    6.     myTransform.parent = parentPlatform;
    7.   }
    8. }
    9.  
    However given that you are editing core code, it might just be easier to write something new. If you have a look at how ledge hang works it has a switch (isLedgeHanging) that when set the normal movement is ignored. If you did something similar you could take the swing controls from the rope code and add it in a similar way to Ledge Hanging.

    - John A

    PS I'm getting close to rewriting ropes using my own physics as Unity physics is just a pain to work with for this kind of stuff.

    PPS Also been thinking about modularising the MoveInXDirection and MoveInYDirection so you can plug in different controllers instead of relying on the platform mechanism. This will make that kind of stuff easier, but also be a very disruptive change.
     
  34. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Also would anyone be interested in entering a competition to produce the best (minigame/demo) using the controller.

    I'd like something to show off the capabilities and I'd be happy to put up a few hundred dollars for a prize.

    I wouldn't require ownership over anything you produce just a license to host a demo on my site so I can link to it in the asset store.
     
  35. suctioncup

    suctioncup

    Joined:
    May 19, 2012
    Posts:
    273
    Hello, just bought your asset and I can definitely say its amazing. One thing though, how do you stop the character from sliding on surfaces? I can't seem to fix it.

    EDIT: Fixed it with a higher drag and higher speed. Seems a bit hacky, but whatever.

    Also, how do you work with the animation updates? I have a custom sprite script which loops my animation, but I don't know how to get it to work with the controller.
     
    Last edited: Jun 1, 2013
  36. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Increase drag in movement settings (try 15-25), and then increase acceleration to ensure you accelerate to the speed you want. Regardless of acceleration you are still capped to runSpeed so if you want "digital" style movement make drag and acceleration both high.
     
  37. Fabian Schempp

    Fabian Schempp

    Joined:
    Jun 1, 2013
    Posts:
    17
    Very nice Controller. I bougth it about a week ago cant wait for 1.5 update.
    Just wanted to know.
    Is there a possibility to set a maximum slope angle? Because it seems possible to walk down straigth walls at the moment, which is pretty cool but not in all situations :).
     
  38. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I should add that for sure. In the meantime make sure your slopes end with 'hard' edges (i.e. close to right angles)
     
  39. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    hi Johnny
    management for the mobile platform is very inconvenient
    can you make the management of individual elements of touch? as in this picture?
    $cont.png
     
    Last edited: Jun 2, 2013
  40. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Hi Player2D,

    I'm not quite sure what that means? Are you talking about the input?

    The sample provided is just the Unity standard assets touch Input, its mainly there to demonstrate how you can wrap a third party input. For a serious game you should probably write your own input or use one of the many touch/joystick packages on the store.

    Once you decide on how you will handle the input converting it to input suitable for the controller is usually only a few lines of code. I've helped people integrate with a number of packages if you decide on your approach I'd be happy to assist you to.

    Although including a quality touch input is a nice to have, the focus at the moment is on improving the core product.

    - John A
     
  41. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    well I understand, thank you.
    I have a "EasyTouch 3.0", but I can not connect it with "2D Platform Controller"
    If you can help I will be very happy.
     
  42. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Hey J,

    Odd question for ya... (but I gather you're well used to odd questions here).

    Anyway this doesn't exactly have anything to do with the platformer directly, but it is something I was thinking bout. Could you have 2 characters going through the game. Basically switchable where the second follows along with your main.. Say if one was your leader, the second had some other skills jumping or fighting. How would the platformer respond to 2 characters?

    thanks,
    B.
     
  43. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Sure, send me a PM or email.
     
  44. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Well performance wise theres unlikely to be an issue with two guys even on mobile. As to implementation I guess you would need some simple AI that tries to follow the player. This AI becomes the input. With complex terrain you would need to detect gaps (maybe an extra raycast ahead of the character, when it doesn't hit something you jump). Of course it doesn't have to be perfect, as you can always have a catch-up mechanism like most of these style of games.

    No promises but if I get some free time I might have a play with the idea. Sounds like it could be fun.
     
  45. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741

    You're a good man, Charlie Brown.
     
  46. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    *cough* no promises *cough*
     
  47. rygaar

    rygaar

    Joined:
    Mar 28, 2009
    Posts:
    63
    How is the mecanim version going?
     
  48. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I'll be looking at that this week, but no progress as yet. Hopefully once I get stuck in to it it shouldn't be too much work.
     
  49. rygaar

    rygaar

    Joined:
    Mar 28, 2009
    Posts:
    63
    Good news. Thanks.
     
  50. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041