Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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:
    5,039
    Still testing for another day or so, then submission, which can be anywhere from 2-10 days ... expect it in about a week.
     
  2. Dan_Tsukasa

    Dan_Tsukasa

    Joined:
    Jan 26, 2013
    Posts:
    155
    Awesome, in that case then I'll drop you an email requesting the WIP, might enable me to get a demo out of my game within 2 weeks after that.

    Update: Remembered I sent you an email about it the otherday, but I can send another if its easier for you.
     
  3. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Could this be used for a physics driven movement solution for lemmings like AI? Please see the below video for how lemmings behave.

    http://www.youtube.com/watch?v=7SgDS-16UFA

    I have an inhouse solution atm using raycasts, but it's not the most performance optimal solution. Curious if your controller could offer better performance with say 20 AI showing the above behavior (basically move left, right, fall, turn, climb ladders).
     
  4. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    I expect my solution would be slower given that it has a lot more going on. Or alternatively that it would be easier to optimize your own solution rather than cut down mine.

    Personally for lemmings I'd look at a bitmap solution where passable/impassable terrain is a 1 or 0 and the lemming is a state machine that decides on its next action based on its current state and the pattern of bits around it.
     
  5. rygaar

    rygaar

    Joined:
    Mar 28, 2009
    Posts:
    63
    How is the mecanim release going?
     
  6. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I see, ok, thanks!


    My game is 2.5D so I've full 3D models.
     
  7. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    JohnnyA,

    I've been working on a much more simplistic arcade style game, and have had to make a lot of adaptations to your code. Some stuff i think is universal and should go into your code base. Also i've made a bug fix here and there. How can I submit it to you?

    Also, I want to extend the RaycastCharacterController class for my custom stuff, but everything in your class is private, instead of protected. Can i convince you to change those variables declarations and include get/set's ?
     
  8. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    You are welcome to submit anything to me via email, but no guarantees on when/if things will make it to the base code. I have a v2 planned which will completely replace movement with a "module" based system where movements are plugged in to the character for a given situations. This will be much more suitable for extension so I'll probably be holding off on most core changes until this is rolled out.
     
    Last edited: Sep 2, 2013
  9. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    It's next... I need to find an aniamtor to work with to sort out a few details, and am still somewhat distracted by the Windows competition... but it shouldn't be too far away.
     
  10. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    What's your email?
     
  11. Madhotdog

    Madhotdog

    Joined:
    Sep 1, 2013
    Posts:
    4
    Hi JohnnyA,

    I just brought a copy of the platform controller, and so far it has saved me a bunch of time. I'm currently working on a multiplayer platform game using the system but I seem to have come across a slight issue when introducing multiple players. It seems that the players can push other players around, but only in one direction. Ideally they shouldn't be able to push each other at all. I was wondering if there would be a potential fix for this?
     
  12. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Characters don't push each other as such... The movement code only interacts with the three layers as defined in the manual (page 3 I think). Any other movement would be coming from the Unity physics system.

    If you are using colliders on the character (for example using the item system), then you might have some issues with your layer set up.Ensure the layers are set up so the character layers don't interact and it should be fine.
     
  13. Madhotdog

    Madhotdog

    Joined:
    Sep 1, 2013
    Posts:
    4
    JonnyA, thanks for your reply.
    I managed to fix the issue by messing around with the rays and ensuring that the character collider was equidistant around the centre point. Works great now!
     
  14. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    I have to say this asset is fantastic , while I did have to tweak it a bit for the type of game I'm using , his asset has saved me an insane amount of time .

    THANKS !
     
  15. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Glad you got it working but it is a bit worrying that you need to change your collider. If your layers are set correctly then the colliders shouldn't matter at all (as they don't affect character movement).

    Specifically make sure your characters collider:

    1. Isn't on the background, climbable or passthrough layer as specified in the RaycastCharacterController settings.
    2. Doesn't collide with itself in the Unity Physics layers configuration.
    3. Doesn't collide with any other geometry (such as background) in the Unity Physics layers configuration.
     
    Last edited: Sep 3, 2013
  16. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Cheers mate, I'd be interested in the modifications you needed to make so I can potentially roll them back in to the product.
     
  17. Madhotdog

    Madhotdog

    Joined:
    Sep 1, 2013
    Posts:
    4
    Sorry I probably should have explained the problem slightly. So I have multiple characters, each with both a RaycastCharacter and a box collider (to prevent them from walking through each other). Occasionally when I was moving one of the characters into another one, the character would move itself out of the way, as if it was trying to reposition itself so it wasn't intersecting the box collider of the moving player. Thanks for creating the controller, it's been really helpful so far.
     
  18. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Okay that makes sense, I haven't really thought of a multiplayer collision system, and to be honest I'm not sure that a proper solution wont require some core controller updates (I expect your solution will have issues if you animate your colliders as the character may collide with itself).
     
    Last edited: Sep 4, 2013
  19. tonyel4

    tonyel4

    Joined:
    Jul 4, 2013
    Posts:
    10
    Hi Johnny!

    I found a bug using rotated and scaled moving platforms. When parenting the character controller to the platform, the scale and rotation of all its childs (sprite, hitbox, etc) gets messed up everytime it stands on that platform. Any ideas of how to fix this?
     
  20. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    It's a Unity bug (discussed passingly in the manual in the ropes section). The work around is not so hard though ... make your game objects uniformly scaled (e.g. scale = 1,1,1) , to get a non-uniform shape change the size of the collider directly (for the visual component you can use a child gameobject).
     
  21. Bast-I

    Bast-I

    Joined:
    May 28, 2013
    Posts:
    18
    Hi Johnny,

    is it possible to use the controller with its horizontal direction not being parallel to the scene's x-axis? If I just rotate the controller, then the rotation is corrected the next time the character is jumping.
     
  22. Dan_Tsukasa

    Dan_Tsukasa

    Joined:
    Jan 26, 2013
    Posts:
    155
    Are you wanting to make a non side scrolling platformer using the Controller?

    For your issue, I'm not at my machine now so I can't check, but I believe you would be able to change the Axis for some things in the controller script, more specifically for the Jump in this case.
     
  23. NADRAC

    NADRAC

    Joined:
    Aug 12, 2013
    Posts:
    7
    Hi ! I bought your Asset because a Youtube video called early mecanim. But for some reason I can't find how to use the animations with your control.
    Reading some posts here I found that the Asset is not working with meca right ? If that is the case how can I replace my character but still be able to use the hero control and the animations?
    I am trying something like in your demo video, were you replace your BOX character with another one, but when playing, I get an error telling me that the animation can’t be found (The one from my character), if I place the one from the hero character I don’t get and error but my character doesn’t move.
    Please help !!

    Thank you
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039

    Mecanim

    The controller works with Mecanim and there are many projects using it with Mecanim. However I haven't released an official Mecanim animator meaning you will need to create your own. That said I do have an unreleased sample, the one from the video, that I can send you if you want a leg up in getting the basics going (just email me with your asset store invoice number).

    The sample Mecanim controller is the next major update so a more fleshed out controller shouldn't be too far away.

    Legacy

    Unlike Mecanim Unity's Legacy animations don't allow automatic retargeting. If you wanted to use the Hero animations with a different character you would need to retarget the animation in your 3D software. I'm not an expert (or even competent) in the animation space, but given a standard biped skeleton is used I'm led to believe its not too difficult.

    If you already have animations for your character that you want to use, then you need to align the names expected by the HeroAnimator with your animation names. There are two approaches:


    1. (Easiest) Change the names of your animations when you import them (either with the import settings or by naming them with the pattern model@animation_name).

    2. (Better) Create your own animator (start by copying HeroAnimator.cs) and change the names of the animations so they match your names (you can find the animation calls pretty easily... they look like this animation.Play("Name") or animation.CrossFade("Name")).

    A few things to note:

    - Names are case sensitive and must match exactly

    - The Hero Animator is not very fault tolerant... it expects all animations to be available. If you don't have one available then comment out the lines that try to access animations you don't have.

    Regards,

    John A

    PS Sorry that the video confused you. I tend to release videos of the upcoming features as I build them so people can see what is coming up. I'll try to make it clearer which are released and which are not.
     
    Last edited: Sep 7, 2013
  25. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Without core code changes no. If you turned off slopes then the characters rotation should be okay (not verified). Jump will be one of the biggest issues as its always vertical in global space. Adding a flag which makes all the movement relative to the character instead of the world is something thats on the to do list... but its probably a while away as it will require a lot of debugging.

    You can always have a go at editing the main code yourself, there shouldn't be too many changes and in the context of a single game you don't need to worry too much about being able to work correctly with every feature.
     
  26. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Dum de dah still waiting on 1.7.1 approval... you can email me if you really really want it now :)
     
  27. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    I (crudely) changed the character input to force the character to keep moving forward, like an endless runner .

    So something like an enum to set it to endless run mode would help .
     
  28. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    A character input that always sets X=1 is my recommendation for endless runners too. I wouldn't consider it crude, its simple and effective... no need to complicate the main controller.
     
  29. Kaemalux

    Kaemalux

    Joined:
    Aug 1, 2013
    Posts:
    45
    Hello JhonnyA! I have looked at your tutorial, and the asset seems great, really nice and featured for a 2d game. Before buying it, i need to know a thing:
    could i achieve a fluid grid movement to set up a turn-based game? I'm having problem in coding it (i'm newbie), and i'd just like to place it in my 2d tile game: i'm building the scene with 2d toolkit tile editor, but when i create sprites it always pass inside walls and objects, instead i'd like to place a custom collider on it and detect if it is a block or wall... If you could gently tell me a solution with your Asset, i will be totally hapy to buy and support it!
    Best regards,
    Kae
     
  30. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    I don't think you would be getting anything worthwhile for a turn based game.

    So as much as I like sales I *waves hand like a jedi* ... don't think this is the asset you are looking for.
     
  31. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
  32. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Very nice !
    I become crazy with this kind of game !!! :)

    6R
     
  33. Kaemalux

    Kaemalux

    Joined:
    Aug 1, 2013
    Posts:
    45
    Oh, don't worry, your Asset is so nice, i'm still buying it, as soon as i can recharge my paypal card! I have already some ideas for it!

    Thanks however for your answer, have a nice day!
     
  34. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Glad you like it!
     
  35. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    431
  36. Bast-I

    Bast-I

    Joined:
    May 28, 2013
    Posts:
    18
    Hi JohnnyA, hi Dan_Tsukasa,

    thanks for your suggestions. I don't want to go too far away from a side-scrolling platformer but, yes, I would find it intriguing to add a little 3D illusion by making the player make a turn every now and then.

    Yes, this actually works! So, with this depending on whether slopes are activated, I would have to tinker with the section "// Apply rotation from slopes" in the controller, right?
    (While turning off slopes is a great work-around for a start, I still want to modify the controller since I'd like both slopes and this kind of rotation to work.)

    It would be great if you could explain this in a little more detail. And how does this depend on whether slopes are activated?To my understanding, turning off slopes just means turning off z-rotation while the problem has to do with resetting y-rotation every jump. Can you indicate where I go wrong?

    Cheers,

    Bast I
     
  37. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    just to be clear I am assuming you want a horizontal axis which is the current x-axis rotated about the z axis.

    The issue with that is that when you press jump the character gets velocity added in the global y direction... not the characters local up.

    By the way have you considered implementing this by moving the camera?
     
  38. Stragen

    Stragen

    Joined:
    Sep 5, 2012
    Posts:
    7
    Hi

    Firstly i wanne say thank you. This platformer has saved us allot of time.

    Lastly,in our game we have the option to have the character fly whenever he wants. Currently you can only move up and down when next to a ladder or a rope. Is there an option to having the character move up and down at any time not needing a rope or a ladder?
     
  39. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    I think there's some jetpack sample code in the pack (don't have it here so I cant confirm, if its not there drop me an email and Ill send it over). That should give you an idea of how you can do flight.

    Exactly how it works depends on how you want your flight to work of course.

    - John A
     
  40. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    v1.7.1 approved.
     
  41. Dan_Tsukasa

    Dan_Tsukasa

    Joined:
    Jan 26, 2013
    Posts:
    155
    Awesome, picked it up about 10 minutes ago!

    Just reading through the additions to documentation now, found a typo, 'The gernal approach for physics should be'.

    Pleased to read you're aiming to try and implement the tree fall from my email, I'd actually say that LIMBO is a pretty solid place to go for for physics related samples, the rope physics, Bouyancy, Weighted objects etc, though I actually believe quite a few things in Limbo are probably done using triggered animations or baked physics and not so often are they realtime physics.

    On the Subject of water though, that might be a really good additional element to add, it'd be harder to walk in, make movement slower but jumps would become dramatically higher ala Sonic 2-3/Knuckles. That said, it'd still be upto the user to try and make the water animate/react to the players presence, and I think thats really the most difficult part anyway.

    I'm currently trying to work out how to set boxes to only be pullable/pushable if they contain a certain tag, as I've more than 1 character, and you change between them to perform various puzzle sections. Each character would have a copy of the boxpuller script attached with the line if gameObject.tag = "?" changed.

    However I can't quite workout where best to place this code in the boxpuller script, I've tried all the combinations that make sense to me but nothing works. I simply want to make it usable only when the box has a certain tag.
     
    Last edited: Sep 10, 2013
  42. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    just picked this one up. looking good, can't wait for the mecanim controller :D
     
  43. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    Hey! I just bought your asset, and it is amazing :)

    I have one doubt, though.
    Is there any easy way to "scale" all velocities of the default prefabs (such as BasicCharacter or HeroCharacter) to a "bigger" world?

    For instance, I am currently developing a pixel perfect game where a screen have 2048 pixels of width, hence 2048 Unity3d's units from one side to the other side of the screen. And the current speeds for the prefabs are set for a world where each 1 Unity3's unity is equal to something like 1 meter, I'd say.

    Is there an easy way to adjust all of these parameters considering "bigger" worlds (where 1 unit is much bigger than 1 meter)?


    Thanks in advance!
    Fernando.
     
  44. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Short answer no.

    You can do it, but its not easy (or at least its easy for me who has done it hundreds of times, but probably not so easy for someone new to the package). Basically most of the movement settings need to change.
     
  45. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Have some time this morning so I will take a look shortly.
     
  46. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    Hey Dan,

    I haven't forgotten you. I just got caught up in this whole terrain creation/Raymans video thingy ... so made a terrain creator instead of solving your issues. Solution coming soonish (PM me if I haven't got back to you by tomorrow).

    - John A
     
  47. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    playing with the mecanim controller... looking good so far, can't wait for the release of the mecanim (humanoid) suported version of this package !
    Please make this a priority :)
     
  48. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,039
    It is a priority but I have a dependency on an animator to get things working properly my 3D animation skills are almost zero.

    - John A
     
  49. kauaiBlake

    kauaiBlake

    Joined:
    Feb 28, 2013
    Posts:
    36
    Hi John A,

    Really enjoying the asset, I like the way you have the code organized and I am learning a lot from it. I do have a question about the best way to make custom modifications to your code (as needed) for the game we are making. I would like to keep things clean, so that I can grab updates from you as they become available, without a nightmare of code merging for every new release of your asset that we want to use.

    Do you recommend we try to keep changes to certain files, like the raycast controller or Hero animator? I saw what you did with the 2d toolkit sample, looks like you put all custom script changes in a separate folder, without sorting like in the main 2DPlatformController folder. Perhaps copying the scripts you want to change into a separate folder then modifying them is the way to go?

    Any advice you can give on this would be greatly appreciated. Sorry if you already talked about this somewhere, I didn't see it in the docs, and did't feel like reading all 9 pages of this forum again looking for an answer. If there is info on the best way to modify your asset already written you can just point me to it. :)

    Again, great asset, just want to use it most effectively.

    Thanks,
    Blake
     
  50. Dan_Tsukasa

    Dan_Tsukasa

    Joined:
    Jan 26, 2013
    Posts:
    155
    Terrain Creation/Raymans video? No idea what that means but I'm pretty interested in hearing about that one.
    I'll drop you a PM in a day or 2 if I hear nothing, as I'm busy with some other bits anyway so I can't even get back to unity for another 3 days.

    Pretty