Search Unity

[RELEASED] Rex Engine: A Unity 2D Platformer Engine

Discussion in 'Assets and Asset Store' started by BeeZee, Jun 20, 2017.

  1. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Kewl:cool: Thanks for the share man, keep up the good work:) Nice game you're working on, got that SHINOBI VIBE look, love it;)
     
  2. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Already Drooling with Excitement :p
     
  3. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I added InControl in engine, and now I can not change the control keys on the keyboard in Input. How do I do it now? And one more question. I want to add actions when taking or causing damage, in which functions to code them (for player and enemy)?
     
  4. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya,

    InControl requires you to do some minor script editing to change its inputs. You can find that under RexPlayerActionSet.cs. Starting on line 41, you'll see different commands being mapped to InControl actions. Here's the Jump code, for example:

    Code (CSharp):
    1. playerActions.Jump.AddDefaultBinding( Key.Space );
    2.             playerActions.Jump.AddDefaultBinding( Key.H );
    3.             playerActions.Jump.AddDefaultBinding( InputControlType.Action1 );
    This is setting Jump to be used with the Space key, the H key, and InControl's Action1 button. If you go down the list, you'll see all the other Rex actions as well.

    To script extra effects when something gets hit, you'll want to look at RexActor.cs. Both the Player and any enemies are already using RexActor, so you can extend that class to make your custom player/enemy class. Then, you'll want to override this method:

    Code (CSharp):
    1. protected virtual void OnHit(int damageTaken, Collider2D col = null){}
    This exists on RexActor, and is called automatically every time the RexActor gets hit. It will also tell you how much damage they took, and it'll pass in the Collider of the object that hit them, in case you want to query any properties from it. So, your version would look like this:

    Code (CSharp):
    1. protected override void OnHit(int damageTaken, Collider2D col = null)
    2. {
    3.      //Your extra effects go here
    4. }
    Hope that helps!
     
  5. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I have some problems with Dash state:
    1. I use "Can Start Dash In Air", and it doesn't work when I Dash from the edge of the platform
    2. I can't Dash while sliding on the wall
    3. After Dash In Air, the player falls to the ground faster than after the jump. It looks a bit unnatural. (And when stepping off the platform.)
    Can I change it myself? I do not require, but it would be nice to have access to such options in the inspector
    Also, it would be cool to add an option that adds an action for the player when falling from a certain height (animation, taking damage, temporary disabling the control)
    Thank you for listening!
     
    Last edited: Jan 14, 2019
  6. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    some nice video for castlevania fans, how a whip works

     
  7. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    1. Can you clarify what you mean on this one?

    2. I just checked, and you're correct! I'd like to add this feature -- I'll try to get it in there in an update soon!

    3. Hm... I tested this, and it looks like what's happening is, the player hits their maximum fall speed immediately when a dash ends, whereas with a jump, because they were previously moving upwards, the upward momentum means it takes a few frames for gravity to fully take over and move them at their maximum downward speed. I hadn't thought about this before, but I agree that it looks a bit weird. Thanks for pointing it out! I'll look into it.

    For the fall damage thing, check out Landing State. That has a field called "Fall Distance for Stun." If it's set to 0, it will be deactivated. However, if you set it to anything above 0, then your player will be stunned when they land from any height greater than or equal to the number you set. There's a slot called "Stunned Animation" which will let you play an animation, and they'll also be unable to move for as long as that animation is playing.
     
  8. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    dash.png
    Thank you for help!
     
  9. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Ah, gotcha. Thanks for the diagram!

    I'll investigate that this week. I'll keep you posted here, and send you an update to test once I've got it worked out.
     
  10. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    Can I ask a question? I tried to add in new script my own method (DOTween animation) for a moving platform, and everything is moving except for the BoxColider. I just need the platform to move with the player, but if I use DOTween, the BoxColider remains hanging in the air when the platform starts moving.
    If I understand correctly, the point is some function from RexPhysics. If it is not hard for you, can you tell me what method I need to fix in RexPhysics for this?
     
  11. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I suspect that probably won't work, at least for the time being. The moving platforms use RexPhysics both for their own movement and to tell any actors riding on them where to position themselves, so if you moved them with DOTween, things riding on them wouldn't move properly.

    The good news is, the upcoming AI update has a waypoints system where enemies can be set to move between any number of different waypoints you define. Once the AI update is out, I'd like to implement the same thing for moving platforms.
     
    lordnasty likes this.
  12. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    So we still have a chance? It seemed to me that it is not so difficult, just need to fix something in the script. Anyway, thanks for the quick feedback. I think I can make the game, what I want, with your engine.
     
  13. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    @BeeZee

    Just want to ask if there's a feature in Rex on the loot drop, somewhat similar to Castlevania, like after killing an enemy it spawn an item, slightly jumps and slowly bounces and settle on the ground then flashes for a few seconds and disappears. The other one is the Drop Loot Auto Flyback to the player.
     
    RainbowWhale likes this.
  14. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I would also like this feature. It would be cool if the loot flew in the direction from which the enemy was killed.
    Sometimes it seems to me that we ask a lot :)
     
    Lars-Steenhoff likes this.
  15. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    How do I change the recovery time after death? It should be in some coroutine, but so far it's hard for me to read someone else's code...
     
  16. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    When will the update?
     
  17. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    At the moment, there's the DropSpawner component, which can be used to make enemies drop loot when they die. I definitely do have plans to update it at some point -- for example, I'd love to make it so it can drop different types of loot based on a loot table.

    As far as making it jump and bounce and such, I'd probably prefer to leave that up to the individual. Since it's more of an animation thing than a functionality thing, you can just use Unity's standard animation tools for that, and set it up how you'd like without running the risk of everyone's project looking homogenized.

    I definitely do want to give loot the ability to fly to the player, though!
     
  18. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yeah, I want to give moving platforms waypoints. It's unfortunately not an easy thing to change in a script, though; there's a surprisingly complex bit of code that goes into making the player move properly while on top of a moving platform. It's not just a matter of making the platform itself move; a lot of additional stuff goes into making objects on top of them move with them.
     
    Lars-Steenhoff likes this.
  19. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    GameManager.cs, line 198. There's a function there called PlayerDeathCoroutine. There's a lot of stuff going on here, where it coordinates between the player dying, the scene fading out, the player reloading at the previous checkpoint, etc., so you'll want to be careful when testing to make sure everything is safe. Additionally, line 146 has a coroutine called "PlayerSpawnCoroutine" which is what gets called when the player spawns back in.
     
  20. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I'm hoping to submit the update later this week.
     
  21. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    In my old project, I made the platform the parent of the player for movement...
    Code (CSharp):
    1. public class MovePlatform : MonoBehaviour {
    2.  
    3.     void OnCollisionEnter2D(Collision2D coll)
    4.     {
    5.         coll.transform.parent = transform;
    6.     }
    7.  
    8.     void OnCollisionExit2D(Collision2D coll)
    9.     {
    10.         coll.transform.parent = null;
    11.     }
    12. }
     
  22. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    New update's been submitted! I'll have details for you all coming soon.
     
  23. iningomontoya

    iningomontoya

    Joined:
    Jul 27, 2017
    Posts:
    21
    I installed the update and now the enemy ai script is missing and the enemy no longer follows player or shoots projectiles.
     
  24. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Is this happening just in the demo scenes, or is this happening if you make a new scene or instance of an enemy, as well? Can you .zip up your project and send it to me so I can test?

    Can anyone else verify if this is happening for them?
     
  25. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Okay, I've talked to a few people now who *are not* experiencing enemy AI issues with the update. I'm still in the process of trying to figure out what's going on, though. If anyone else can verify, I'd greatly appreciate it!

    In the meantime, make sure as always to back up your projects before updating.
     
  26. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Okay, seems good. The Enemy Template used when you create a new enemy from a template is having trouble finding the Enemy AI component, but it's fixable just by dragging EnemyAI.cs onto its Controller. Enemies that are already in the game seem unaffected.
     
  27. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    There is one problem: if you make a Dash or Double Jump during the fall from the specified height, the player will still be stunned. It is illogical to punish a player after Dash or Double Jump.
     
  28. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    when dying in the air in the demo scene when in flight mode, the player just stays in the air, it would make sense if gravity kicked in and he falls down on the ground
     
  29. yurilin1

    yurilin1

    Joined:
    May 22, 2013
    Posts:
    102
    Hi,does the game have the function of seperated area minimap
    like metroid or AxiomVerge.
    I think the minimap,saveload,cutscene system,main menu and in game config/inventory/powerup UI menu were neccessary for completely comerical quality game. Although many developers were high experieces programmer,they still have no engery to work these by individual. Once people buy an engine,they may always think of to make a high commerical usable game but not focus too much on progrom.
    If you could focus on develop on these section, I think you engine would be overwhelming and ton of people would buy.:oops:
    Thanks:D
     
    Lars-Steenhoff likes this.
  30. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Yes I would love a mini map system, and save load
     
  31. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    That's a good point! I'll look into it. Thanks for bringing it to my attention.
     
  32. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I'm adding new features to Rex pretty much constantly. There's tons of stuff I'd love to add going forward. I've definitely considered a lot of the stuff above, although a big part of me also wants to keep Rex tightly focused on platforming mechanics; I'm very concerned about bloat, and there are other assets that can do the other things you're talking about. So, we'll see! I won't rule anything out.
     
  33. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    What asset can do minimap? I have been looking but have not found any

    And don't worry about bloat

    If its core things like saving and loading those things are actually hard to integrate for non progammers even when there are packages out there that say they are made for it
     
  34. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    Hi,

    I'm fiddling around with the parallax scrolling of the backgrounds/foregrounds. I see that there are separate camera's for these different layers, is it also possible to tweak the parallax scrolling speed for those?
     
  35. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    There was an asset by the developer that did Platformer-Pro, but it got deprecated around early 2018. Sadly, you can not obtain this asset anymore as it was taken off the store after said developer had to move on due to life complications.

    A scaled down Super-Metroid style mini-map shouldn't be all that difficult. All you would need to do is to place an object with a simple script on the singleton. Said script would use a 2d grid system which would set any map nodes tiles to visible and paint the map tile the player is currently visiting to whatever color you want as a designer. Most practical way would probably be to create the graphical nodes within an ui element in the corner of the map.

    A lot of successful assets have started listing user-made extensions that are useful. Perhaps going this route on very specific stuff would be the way to go since BeeZee has enough on his plate and it would encourage us to sharpen our skills with scripting with the asset.
     
    Last edited: Feb 5, 2019
    Lars-Steenhoff and BeeZee like this.
  36. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep, sure is. RexCamera.cs. Starting on line 250, you'll see this:

    Code (CSharp):
    1.  
    2. float backgroundOffset = 0.35f;
    3. float midgroundOffset = 0.5f;
    4. float foregroundOffset = 1.2f;
    Those are the scroll speeds for the background, midground, and foreground cameras, respectively (relative to the default layer that characters are on, which scrolls at a speed of 1.0). Feel free to change those values to anything you'd like.
     
  37. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    Turns out a dumbed down Super Metroid style minimap isn't hard at all. I just put an array of UI sprites on the singleton and made a crude representation of the rexdemo game world and then just used onRexSceneManager.Instance.GetCurrentLevel() LateUpdate to determine the desired colored for the currently visited area and set alpha to any areas previously visited. Obviously using LateUpdate each frame will not be acceptable for a release. I'm thinking it would be best to keep the minimap object off the singleton object and do a simple check on all the game world's scenes on if they were visited or not on OnSceneLoaded() function since it should only update on scene change. I do believe you will need a few lines of code on the RexSceneManager script for it to know what areas you have or have not visited.
     

    Attached Files:

    Last edited: Feb 5, 2019
    BeeZee likes this.
  38. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    This is super cool! Thanks for posting about it.
     
  39. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526

    I you put it on the asset store I will buy it
     
  40. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    MinimapV2 SS.png

    I updated my Minimap extension and added the ability to create enemy health bars on the sceneview itself as well as some bugfixes (Charge shots overwritting vertical directions & player being allowed to use melee_UP with it's ground animation while flying). Follow the instructions on the achive to install it on a fresh project for a demonstration and feel free to improve on it and then share.

    2/11 Updated to include 8-way ladder climb and minimap sprite files and a few other minor things.
    2/17 Uploaded my improved Subweapon options and better transition effects as well as some minor fixes.
     

    Attached Files:

    Last edited: Feb 18, 2019
  41. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Awesome share man, thank you so much, this is one of my to do in my project list. :cool::)
     
  42. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    This is super cool. I appreciate you sharing this! I'm excited to dive into it. Probably as soon as AI is ready for beta -- I'm feeling pretty behind on that, so I'm trying to hustle to get it ready for everyone!

    EDIT: Is it cool with you if I show this on Rex's social media? I can credit you -- feel free to let me know what name you want me to use, if so.
     
  43. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    Yes, you can credit me as just hodgepodge. You might want to do a brief code review first as new bugs might have been introduced with the new features.

    8WayClimbPrototype.png

    Anyways, I updated my extension pack to include the map sprite files and included a rough 8-way ladder climb prototype. Obviously, going forward with the feature the ladder object should eventually be tagged with a new 8way climb tag and ladderState.cs be extended to run the proper conditions for the two ladder states as the prototype code simply overwrites 1-way ladder climb.
     

    Attached Files:

    FunkyBuddha likes this.
  44. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    will this work with 2.5d??
    like using 3d models instead of 2d sprites??
     
    BeeZee likes this.
  45. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep, it'll work with 3D models (or any other art style you'd like). Just give them Collider2D's, and you'll be good to go.
     
  46. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Shared! Much appreciated.
     
  47. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    This is an HP Branch for the upcoming Rex AI. It lets you perform different actions depending on the HP of the target. You can choose if the HP has to be greater than, equal to, greater than or equal to, or less than or equal to an amount, and you can also perform the check based on a fixed amount or a percentage of total HP!

    In this example, the enemy will do a melee attack if its current HP is greater than 90% of its total HP, and a projectile attack if not.

     
    Picmo, hodgepodge2022 and CHEMAX3X like this.
  48. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Hey all, I'm going to shoot for early next week to get the AI beta out to the beta testers! It's ready to go, and I'm just preparing some documentation for you. Thanks for your patience!
     
    Lars-Steenhoff and CHEMAX3X like this.
  49. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Can't wait <3
     
  50. RushingEntertainment

    RushingEntertainment

    Joined:
    Sep 28, 2018
    Posts:
    16
    Awesome news mate, thanks for all the love and work you put into this.
     
    BeeZee likes this.