Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Ohh i see, thanks for the explanation, and, how can i enable the collider through code ?

    And one more question, may i ask, why did you choose 7.35 as cam size ? i couldn't find that in the documentation, and if the cam size is 7.35, why the boundary Y size is 7.275 instead of those 7.35

    Btw, i think i found a bug, i took Booster from the demo and i created a player from template and i saw the same bug, when you dash in slopes the player goes through the collider:

    dash.gif
     
    Last edited: Apr 25, 2019
  2. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    The collider is just a standard Unity BoxCollider. You could call the following at any point:

    Code (CSharp):
    1. GetComponent<BoxCollider2D>().enabled = true;
    The camera size is arbitrary, except that it's in a 16:9 ratio. You can adjust the zoom to any amount you'd like.
     
    CHEMAX3X likes this.
  3. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Yes i know, is just too specific that 7.35, i though there was other reason to choose it instead of the default one, which is 5, but well =P

    Thanks again
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    I'm using pro camera 2d, and I don't see the screen shakes

    Any idea what I should do to active it?
     
  5. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya. For the first one, you can, although it'll take some minor scripting. If you open up GroundPoundState.cs, you'll see this line at the top of the Update() method:

    Code (CSharp):
    1.                 bool isGroundPoundAttempted = controller.slots.input && controller.slots.input.IsDownButtonDownThisFrame() && !controller.slots.physicsObject.IsOnSurface() && controller.StateID() != WallClingState.idString && controller.StateID() != LadderState.idString;
    2.  
    You can replace the controller.slots.input.IsDownButtonDownThisFrame() bit with this:

    Code (CSharp):
    1. controller.slots.input.isSubAttackButtonDownThisFrame
    ... and that should do the trick.

    For part 2, I intentionally didn't give the regular Enemy.cs class the launching effect because it's purely cosmetic, and I think it makes for more unique projects if everyone does their own cosmetic stuff. That said, you can replace any enemy with the DemoEnemy.cs script by looking at an enemy's Enemy component in the Inspector. At the bottom, you'll see a header called "Editor Options". Inside that, there's a header called "Swap Rex Actor Script." Inside that, in the text field, type in the following:

    RexEngine.DemoEnemy.cs

    Then hit the "Swap RexActor Script" button, and it should replace the Enemy.cs component with the DemoEnemy.cs component.
     
  6. Eireenevan

    Eireenevan

    Joined:
    Jan 7, 2018
    Posts:
    3
    Hello,
    I just updated with version 1.52. Unfortunately I have the following error :
    Assets\RexEngine\Scripts\RexEngine\_Editor\RexMenu.cs(19,56): error CS0246: The type or namespace name 'MapEditor' could not be found (are you missing a using directive or an assembly reference?)

    I am in Unity version 2019.1 but I also tried with the 2017.4.26 version of unity and I have the same problem.
    Can you help me please ?
    Thank's
     
    BeeZee likes this.
  7. jhasselbach22

    jhasselbach22

    Joined:
    Sep 15, 2018
    Posts:
    3
    Just came back after a long break and working on a new project and getting the same issue as you Eireenevan. Love all the updates and cannot wait to start working with Rex Engine again. Any update on this error by chance BeeZee?

    I am also using 2019.1.0f2 if that helps and Thank you!
     
    BeeZee likes this.
  8. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for letting me know. I've been having some weird issues lately with things getting uploaded that were specifically checked to *not* be uploaded. My apologies -- I'll figure out why that's happening and make sure it stops.

    Fortunately it's an easy fix, though. Open up RexMenu.cs and delete lines 15-22. That should do the trick.

    EDIT: I'm attaching a fixed version of RexMenu.cs here. You can replace the RexMenu.cs file in your project with the attached one and it should fix everything.
     

    Attached Files:

    Last edited: Apr 29, 2019
    CHEMAX3X likes this.
  9. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Hey @BeeZee, so i updated to the latest version, and im facing a lot of problems with my attack animations:

    ata.gif

    The first one, if i walk, and hold the arrows and press the attack button, i have this issue where the attack animation is overridden by the walk one.

    The next one is the air attack animation, if i make the attack almost reaching the floor, the attack is overriden by the landing animation.

    And the last one, is similar but with the shot animation, being overriden by the landing one, and then the shot animation continues till it ends.
     
  10. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Hm... that's odd. Nothing about those changed in the last update. I'm testing those on my end and I'm not able to replicate -- my attack animations (both the Actor animations and the Attack animations slotted) continue even when other animations happen.

    I think this same thing happened with your project once before, right?

    If you want to PM your project to me, I can take a look. I've been debating making a few changes to the way Rex handles attack animations, but I'm not 100% sure yet, so this might be good data to have.
     
    CHEMAX3X likes this.
  11. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Sure thing, i'll send it to you, tthanks (=
     
  12. hedberggames

    hedberggames

    Joined:
    Jan 11, 2019
    Posts:
    6
    Hello,

    I've been using Rex Engine the past few months to prototype a game I'm planning, and I've really enjoyed working with it! I am very grateful to have the source code available (my background is in programming, so seeing the code helps me understand how to use it) and the new AI system has been really helpful for testing the game's feel against a variety of different AI difficulty levels.

    I'm preparing to gather public feedback on that prototype and I thought this was a good time to finally reach out, both to thank you for this awesome tool, and also to ask a few questions:
    1- Have you considered adding Rex Engine to the tool database in itch.io? I wanted to add "Made With Rex Engine" to the prototype's metadata, but I didn't see it in the list of tools/engines. (In case it helps, here's the form to add an entry to the list.)
    2- Do you have a recommended approach for adding new kinds of behaviors for the AI? While investigating adding a new event (to detect distance from dangerous projectiles), it seemed like the list of events that display in the UI was hardcoded, so I wasn't sure what the right approach was. (Eventually I realized modifying the Distance event to detect projectiles was not too difficult, so that's how I solved that particular challenge.)
    3- Have you looked at the performance of the Camera Helper? When I profiled my prototype, I discovered that the calls to Camera.main were the bottleneck for me (I have hundreds of decorative sprites in the scene, and apparently Camera.main walks every object in the scene every time it's called) I was able to fix my performance issues by caching the camera so that it was only called once per frame, so I thought I should mention it in case any of that information is useful for you.

    Thanks again, it's been a delight to use Rex Engine, and I'm looking forward to continuing to use it in my future projects.
     
    Lars-Steenhoff and BeeZee like this.
  13. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    It's funny you mention that -- I was literally just looking into this the other day! I appreciate you bringing it up. I'm planning to have something up there soon.

    I'd say pretty much any time something like this is hardcoded, it's on my radar to make it not-hardcoded in the future (I totally recognize that hardcoding is bad practice, but I occasionally still fall back on it anyway!) I haven't looked into this enough yet to have a better idea off the top of my head, though. I'll keep you updated via the forum here if and when I change it, but in the meantime, updating the hardcoded list is probably still the best way. The main place you'll want to check is InspectorHelper.cs.

    This is *very* helpful info! Thanks a ton. I'll investigate and make a version where the camera gets cached. For reference, could you PM me your version so I can profile it?

    Lastly, I really appreciate the kind words! Rex is still mostly a passion project for me, so any time I hear that it helped someone, it really makes my day. (If you'd be up for leaving a review on the Asset Store, those help me a ton, as well! But no pressure either way.) So, thanks again! It means a lot to me.

    EDIT: I'd also love to see your project when it's ready!
     
    Lars-Steenhoff likes this.
  14. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Okay, I've got solutions for you! Neither of these things are new relative to the latest update, so I'm not quite sure what was happening there, but they're pretty easy to fix, regardless.

    For the first one: on your melee combo chain (the ground-based one -- "Melee1" and "Melee2"), you need to expand Actions Allowed During Attack and check the "Ground Moving" box. If that box isn't checked, then the attack won't allow ground-based moving to occur while it's executing -- hence, moving will interrupt it.

    For the second one ("MeleeAir"), you need to slot an AnimationClip into Actor Animations > Standing. It can be the same clip you used for the jumping attack animation. What was happening is: your character was landing, and you had an AnimationClip slotted for landing, but not for the attack itself when the character was grounded. Since there was no AnimationClip for the attack itself on the ground, it was getting overridden by your regular Landing clip as soon as you landed.

    As best as I can tell, your jumping shot animation isn't being overridden by anything -- I'm able to successfully jump, shoot, and land, and the shot animation plays straight through to the end without interruption.
     
    CHEMAX3X likes this.
  15. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    does this have 3d model support?
     
  16. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep. You'll want to constrain all the action itself to a 2D plane -- so you'll want to use Collider2D's for your physics -- but you can use any type of art you want, including 3D models.
     
  17. ikhoata

    ikhoata

    Joined:
    Mar 16, 2013
    Posts:
    1
    Hi, I imported the Rex Engine 1.52 using Unity 2017.4.26f1 and got this bug:
    Assets/RexEngine/Scripts/RexEngine/_Editor/RexMenu.cs(19,56): error CS0118: `RexEngine.RexMenu.MapEditor()' is a `method' but a `type' was expected

    Is this Unity version unsupported? Also I tried to find MapEditor file but couldn't find it in the asset.
    Please help.
    Thank you.
     
  18. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    So I can create a 2.5d game with it with no problem?
     
    Lars-Steenhoff likes this.
  19. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep, as long as the action itself is on a 2D plane, you should be good to go.
     
  20. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya,

    I just responded to your email with a fix. Apologies for the bug!
     
    Lars-Steenhoff likes this.
  21. jaelove

    jaelove

    Joined:
    Jul 5, 2012
    Posts:
    302
    I will purchase this awesome asset! thanks for the quick responses. One feature I would love to see is a stealth hide mechanic similar to Blackthorne, Mark of Ninja and Bruce Lee return of the Legend for GBA.
     
    Lars-Steenhoff and BeeZee like this.
  22. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    This one i have it like that cuz i dont want my player to walk when attacking, that's why is like that =O

    Got it i'll do that =D

    This one is kinda tricky,it has to be done almost reaching the floor.

    But even with those solutions, its still weird, i have a backup from December(with an older version of Rex of course), i just copied my player, which is working perfectly fine there, and i imported it to a new project with the latest version of Rex, and i got those animation problems
     
  23. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Ah, okay, yeah, I see what you're saying. So the idea is to do it like Castlevania, where the player stops in their tracks when they attack, but the attack itself continues to get carried out?

    It's odd -- I'm testing the remake of Castlevania 1 that I did in Rex Engine, but using the latest version (1.52), and that same thing works there. I'll investigate more in the morning, and I'll also try swapping some older versions of the Attack script into your project to see if that changes anything.
     
    CHEMAX3X likes this.
  24. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    I'm testing, and i still see those problems, but in my old project no, i can send you more gifs if you want, to see that i'm not lying xD hehe =P.

    ata2.gif
    (You have to press the attack button almost at the ground, sometimes as soon as the player touches the ground, press the attack button, and you'll see it)

    But it's ok, take your time, thanks for da help as always ='D
     
  25. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Okay, I ended up testing just a little bit more just now. I grabbed a much older version of the Attack script (from about 6 weeks ago) and put it on your character, and it didn't change anything.

    However, I tried something else after that: I took the AnimationClips you had slotted under "Attack Animations" on your attacks, and slotted them into the same slots under "Actor Animations." That made the ground attacks stick around after the character stopped moving.
     
    CHEMAX3X likes this.
  26. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265

    I did this too, but for me it didn't work, actually with the shot animation, my player stays in that animation till i attack xD : ata3.gif
     
  27. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I also noticed something a little weird about your setup for the attacks: you've got an Animator on each attack, but the attacks don't actually have their own sprites that are being animated; the player's regular sprite is the only one being animated upon, so the extra Animators on the attacks are redundant. (Those are typically there for if you've got a separate animation playing for the Actor and the Attack itself, like how Booster has the animation where he swings his arm, and then his wrench has the separate animation of it slashing downward; those are two separate pieces, hence the two separate Animators.) In your case, I'd remove the extra Animators from your Attack components, and then put all of your AnimationClips in the "Actor Animations" slots, leaving the "Attack Animations" slots empty.
     
    CHEMAX3X likes this.
  28. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    I tried once to have separate animations like yours (you actually recommended me that too), but still, even if those animators are there, is the player from an old project, and there it works fine, with or without those animators, anyways, i'll set it up as you said, thanks man again for your help <3
     
  29. hedberggames

    hedberggames

    Joined:
    Jan 11, 2019
    Posts:
    6
    Thanks, I was mostly trying to figure out if I had missed something, so it's good to know that it's extensibility hasn't been designed yet. I'm perfectly happy to work with it being hardcoded. If/when you do look at making it extensible, I'd be happy to provide some example use cases for it, if that would be helpful.

    I'm really glad it made your day! I have a tendancy to not reach out, so it's reassuring to know that you're glad that I did.

    Thank you very much! I'm getting everything together so that it should be ready by Monday, so I will post a link to it then.
     
    BeeZee likes this.
  30. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Thanks @BeeZee for the quick update, it solved the problem with my animations =D
     
    BeeZee likes this.
  31. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Rex Engine 1.53 is now live! Here's how you can use it to pull objects backwards:

     
    DrOcto, IXTLIA, CHEMAX3X and 2 others like this.
  32. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Did you change the art? looks more colorful, like a GBA game =D
     
  33. hedberggames

    hedberggames

    Joined:
    Jan 11, 2019
    Posts:
    6
    Pushing and pulling a crate looks good (I especially like the animation that plays when you finish pushing), but I'm quite curious how they interact with PhysicsMovers and RexActors: can you push/pull a moving platform or NPC? I can imagine a lot of interesting design potential opening up if you can easily mix those together (the Ice Wall from Megaman and Bass jumps to mind as a great example of a pushable object that has other physics interactions.)

    Also, I checked 1.53, to see if it icludes the performance improvements for the camera, but it looks like it might not be fully implemented yet: GetLeftEdgeOfCamera looks good (it's using the cached camera) but the other three GetEdgeOfCamera methods (Right, Top, and Bottom) are all still using Camera.main. GetScreenSizeInUnits also has an inconsistency: most of the method is using the cached camera, but the height is calculated from Camera.main.

    Here's an early prototype on itch.io. It's called Magic Training Prototype, and it's a short vignette, focused on combining gameplay (built on Rex Engine), narrative (built on Yarn Spinner), and player agency. I'm looking to get feedback on it, so if you'd be willing to try it out and let me know what you think, I'd really appreciate it. (No pressure, though.)
     
  34. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for pointing out the camera thing! There's definitely easy room for further optimization, so I'll get that in the next update.

    The idea with PhysicsMover is that it's something that moves the physics of another object. So things like Ice are a PhysicsMover, as are moving platforms and conveyor belts, because they add to the physics of whatever object is on top of them. if you check out MovingPlatform.cs, for example, you'll see that it extends PhysicsMover and it has code in there for handling how other objects behave when they're on top of it.

    If you search in the project files, you'll see that there's a PushableBlock.cs script. I want to do a little bit more work on it, so I think i left this script off of the actual PushableBlock prefab for the time being, but if you want to check it out in the meantime, you can drag on onto a PushableBlock prefab. It extends PhysicsMover as well, so it means that anything standing on the block when you push it will also get pushed along with the block itself -- so I think that would qualify for something like the Ice Wall subweapon (sidenote, always great to talk to another Mega Man and Bass fan! I feel like that game got really overlooked.)

    I'll check out your game a bit later tonight! I'm excited.
     
  35. hedberggames

    hedberggames

    Joined:
    Jan 11, 2019
    Posts:
    6
    Thanks for the explanation about physics movers, it sounds like they behave a bit differently than I had first thought, so it's good to know what exactly they are used for. I tried out the PushableBlock class, and that's moving things that are on top of the block, so that does sound right for what I was looking for. Knowing that you want to make changes to it, I'm thinking I might wait for those before I really dig in and study it (no rush, though - I've got plenty of other things to study up on in the meantime.)
     
  36. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Hi I'm trying to make a pixel perfect camera and have used the rex camera with the unity pixel perfect compnonent
    https://forum.unity.com/threads/pixel-perfect-preview-package.533433/

    But there is one problem when I get the the edge of a level, the camera jumps/snaps to the edge in a way that's not pretty.

    To test out my findings just download the official unity pixel perfect package and add it to the camera.

    It would be nice if this package will be officially supported by Rex Engine as I think many people would like to have pixel perfect camera.

    Thanks!
     
  37. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I just tested this on the Rex demo with the following settings:

    Assets Pixels per Unit: 16
    Reference Resolution: 320x180
    Upscale Render Texture: Off
    Pixel Snapping: Off
    Crop Frame: Off

    Seems to work without any issues. It might just be your settings?
     
  38. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Thanks for testing it out! It could be my settings , I had the same settings except for resolution :
    512x288

    I think that may be the reason, can you try this resolution and then walk to the middle of the screen and then walk back to the left of the screen, here it jumps / snaps to the edge.

    The reason why I picked that resolution is that its a true 16:9 pixel aspect ratio.
    https://pacoup.com/2011/06/12/list-of-true-169-resolutions/
     
  39. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I was able to replicate the snapping issue with 512x288. It went away again when I changed the "Assets Pixels Per Unit" value -- I think there's just a sweet spot where you might have to get the values to line up.
     
    Lars-Steenhoff likes this.
  40. hedberggames

    hedberggames

    Joined:
    Jan 11, 2019
    Posts:
    6
    I've been looking a bit at this too, and I think I found a clue about what may be going on by looking in the pixel perfect camera's code: the code runs every frame and modifies the camera's orthographic size (among other things.) I noticed the Rex Camera uses orthographic size to calculate its boundaries, and doesn't seem to do it nearly as often, so recalculating the camera boundaries more frequently might help keep the camera inside the bounds so it doesn't pop around as much.
     
    BeeZee and Lars-Steenhoff like this.
  41. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Thanks
    What was the value that worked ?
     
  42. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    I tried 32 with reference resolution 512x288 and I don't see the snapping, but everything is too much scaled up to my liking.
    I also tried 32 with a reference resolution of 1024x576 to keep the scale and it has the bad snapping again.
    Perhaps the solution is where @hedberggames pointed to?
     
  43. SkyMan77

    SkyMan77

    Joined:
    Jan 15, 2018
    Posts:
    23
    Hi,

    I'm planning to make a game, similar to Kirby Nightmare in Dreamland on GBA.

    Do you think your tool would be helpful? Do you think that there are few of things that it won't let me do the same way? If so, why?
     
    BeeZee likes this.
  44. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya SkyMan77, thanks for checking out Rex! It means a lot to me.

    I'm definitely a big Kirby fan. I played a bunch of Kirby's Adventure in particular as a kid, which I think Nightmare is based on?

    Off the top of my head, Rex will definitely help with a lot of that. It'll give you all the core movement stuff, and it should be pretty easy to get your player character set up to play like Kirby, including most of the flying/multi-jump stuff Kirby can do. You'd need to create your own system for earning enemy powers, if you're planning to do a similar thing to how Kirby inhales enemies and copies their abilities, but Rex has a pretty robust system for player attacks and abilities that makes it easy to toggle abilities on and off at will, so it'd get you a good portion of the way there. It also has a comprehensive enemy AI system that should let you recreate Kirby style enemies and bosses; I'm trying to go through the Kirby's Adventure bosses in my head, and at least from what I'm thinking of so far, pretty much all of them should be doable.

    Hope that helps! Feel free to let me know if you've got any other questions.
     
  45. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I tried 22, I think, and that worked out. It might also just take a bit of finessing with the artwork itself -- if things are getting scaled up too much, you can always change the PPU values on the sprites themselves to make them smaller.
     
  46. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    At 22 I still have the snapping, would you know how I can set the rex camera calculate the orthographic camera per frame?
     
  47. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    CHEMAX3X likes this.
  48. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
  49. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Got a new tutorial video! Bazooka Rex gets some fangs in this one.

     
    CHEMAX3X and Bagnol like this.
  50. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    @BeeZee, idk if this is a bug or if it should be like that, but the attacks take damage x2, like attacking 2 times in one attack, i enable the option to show the damage, so if my enemy has 8 HP, and every attack makes 1HP damage, instead of taking 8 hits to kill the enemy, it takes 4, and i don't want that xD, look :

    damage.gif


    Thanks =D
     
    Last edited: Jun 5, 2019