Search Unity

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

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

  1. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Just for fun, and as a separate example, I started building a Super Mario Bros.-style Thwomp enemy with the AI. Took me literally less than five minutes. I'm so pumped to share this with everyone.
     
  2. RushingEntertainment

    RushingEntertainment

    Joined:
    Sep 28, 2018
    Posts:
    16
    I feel this is all Rex Engine needed to be fully complete. With a robust AI like the one you made, not only enemies and bosses will be easier to make, but also platform mechanics in general.

    Thanks man an congrats!
     
    BeeZee likes this.
  3. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    Subweapon.png
    I decided to add yet another extension that I think would benefit a lot of users. This one allows you to select both a primary and secondary subweapon and select them from either the pause menu like in classic Megaman games or select them real-time with the assigned key you gave like in Megaman X. I should upload this in 24 hours or so as I want to do further testing on the added features.
     
  4. NaynayNeko

    NaynayNeko

    Joined:
    Feb 15, 2019
    Posts:
    1
    hello guys first forgive my english is not good and i am not so good at c# code
    i want ask some basic question
    if i want make some item or trigger collider to give my character like dash ability or sometime i want cancel some ability in the scene
    and i want made if player in enemy sight enemy will track the player
    what should i do ?
     
    Last edited: Feb 17, 2019
  5. hodgepodge2022

    hodgepodge2022

    Joined:
    Mar 8, 2015
    Posts:
    19
    Transitions.png

    As promised here is my latest pack of extensions. This one adds the subweapon changes shown above, and simple stage transitions. Currently the subweapon does not play nice with player actor's getting switched out and the transition script is very limited, however you should be able to replicate stuff like a standard pixalation transition effect and a Mario 64-like death transition with very little work.
     

    Attached Files:

  6. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Sweet :cool: Thanks for sharing man.
     
  7. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    @BeeZee

    About the background music, is there a feature in Rex that we can control the background music's : volume, stop, pause, play and change the music inside the scene?
     
  8. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Hey guys, just wondering if someone tried Cinemachine with Rex, i want to know if it works fine =O
     
    andreiagmu likes this.
  9. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep. It'll involve a minor amount of code at the moment, so I'll walk you through it:

    • First, put all the abilities on your player prefab to begin with. For the ones that you want to be inactive at the start, uncheck their "Is Enabled" checkbox.
    • Then, when you want to enable them, you can reference them in code and set "isEnabled = true." For example, here's what I'd do if the player had a Dash ability, and I wanted to enable it when they touched a trigger:

    Code (CSharp):
    1. protected void OnTriggerEnter2D(Collider2D col)
    2. {
    3.      if(col.tag == "Player")
    4.      {
    5.           col.GetComponent<Player>().slots.controller.GetComponent<DashState>().isEnabled = true;
    6.           GetComponent<BoxCollider2D>().enabled = false;
    7. }
    You could do the same in reverse to disable an ability:

    Code (CSharp):
    1. col.GetComponent<Player>().slots.controller.GetComponent<DashState>().isEnabled = false;
    Activating enemies by line-of-sight will be possible in the upcoming enemy AI update.
     
  10. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Sure thing. RexSoundManager has a bunch of commands you can use:

    Code (CSharp):
    1. public void SetMusic(AudioClip _track, bool willLoop = true, float _volume = 1.0f)
    2.  
    3. public void Fade()
    4.  
    5. public void FadeIn()
    6.  
    7. public void Mute()
    8.  
    9. public void Unmute()
    10.  
    11. public void Pause()
    12.  
    13.  
    You can set the volume on the fly by calling SetMusic, and just passing it the same AudioClip that's already playing (it won't restart the song if it's the same one that's playing already.)

    You can access any of those methods from any script by calling:

    Code (CSharp):
    1. RexSoundManager.Instance.Fade();
    (Replace "Fade" with any of the other functions I listed above.)
     
    FunkyBuddha likes this.
  11. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Wow, you're in full beast mode! This is awesome. I'm really excited to dive into all this stuff!
     
  12. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's a quick and dirty video of the Thwomp enemy AI routine in action. I'm planning to put in animations and sound effects for the full release; I just wanted to show this guy off in the meantime.

     
  13. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Question for those on the AI beta: does everyone have Discord? If so, can you PM me your screenname?
     
    NaynayNeko and CHEMAX3X like this.
  14. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Sent (=
     
    Last edited: Feb 20, 2019
  15. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya all, invites for the AI beta should be in your inbox now. If for any reason you were signed up but didn't receive an invite, PM me and I'll take care of it.
     
  16. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    @BeeZee I have a little issue, so i want to add a capsule collider to my player cuz i'm using Ferr2D and i have "weird terrain shapes" x) so with the box collider my player get's stuck, i'm trying to add the capsule collider at the bottom of my player in thefeet, but it just get's totally ignored:

    Captura de pantalla (2860).png (The collision starts in the red line where the Box collider is, and as i said, the capsulle collider is ignored).

    So, is there a way to make it work ? or to replace the Box collider totally with a capsule collider ?

    One more thing, i think i found a bug, in the dialogue system, the animations are overridden (i'll post a gif later), for example if an NPC has an Idle animation and a Talk animation, to pass from one to another, the animation itself doesn't finish, let's say if in the idle the NPC has the arms up and the dialogue starts and the talk animation is with the arms down, it cuts the Idle anim and play the talk, so as a result you have in one frame the arms up and the next one the arms down, it's not blended like the player animations.

    It's hard to explain with text so i'll upload a gif later =O

    ****EDIT**********

    NPCBug.gif
    Here you can see what im talking about, before starting a dialogue and finishing it, the animations are not blended properly
     
    Last edited: Feb 23, 2019
  17. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    No, Rex wasn't designed to work with capsule colliders. I do use Ferr in a lot of Rex projects, though. I'd recommend using primarily 30, 45, 60, or 90-degree angles, and avoiding concave shapes. One thing I love about Ferr is that you can edit the visuals of a terrain edge to make it *look* like it's slightly different from where its actual hitbox is. This means you can have terrain where the collision adheres to a loose grid system (which I'd argue feels better anyway, but that's just me, and that's a tangent I don't want to go off on), but the visuals can have the variation you'd want from something like Rayman or Ori.

    Thanks for pointing this out! I'll look for the .gif when you've got it uploaded.
     
  18. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Ohh ok, so i guess i'll work with more simple shapes then x)


    Uploaded (=
     
    Last edited: Feb 23, 2019
  19. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Hey again, have you managed to look into the jump-through issue? I *believe* it's because tilemaps are generally optimized so adjacent tiles are treated as a single collision, rather than treating them seperate if they're all attatched, which screws with jump-throughs which need to be able to detect collisions with the top-most pixels on a downward trajectory of every tile (but I could be wrong! :D )

    Has roll been considered yet? I'd love have fun with a sonic-roll out of the box :D
     
  20. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I haven't had a chance to look at the tilemap thing yet, but I think your explanation here makes a lot of sense. If it's being all treated as a single collision, that would probably break it.

    No roll yet, although I agree that it would be a lot of fun.
     
  21. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for the image! I'll look into it once the AI beta finishes up.
     
    CHEMAX3X likes this.
  22. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Sure thing =D
     
  23. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    For everyone on the AI beta: I uploaded a new version this morning with some additional features, QoL improvements, and bug fixes. If you're on the Discord channel for the beta, the link is there. If not, send me a PM and I'll get it to you.
     
    CHEMAX3X likes this.
  24. HalfJapaneseDude

    HalfJapaneseDude

    Joined:
    Feb 21, 2019
    Posts:
    1
    How might I sign up for the beta? xD
     
    BeeZee likes this.
  25. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I would like to remind you of this issue =)
    ---
    1. I increased the height of the player's boxcollider to 2.5 units, and problems with physics began (but everything works well with the 1.8 units.). My player jumps to a height of 3.5 units, but at the same time, while jumping, he can “run” onto a platform with a height of 4 units or more, but his collider should disturb him. I would like more accurate physics.
    2. If you change direction when falling, the falling animation plays again, it doesn’t look natural.
    3. And is it possible to add a direction to which the player will look, when I walljumping. I need him to look away from the wall. Maybe add this to the inspector.
    32.png
     
    Last edited: Mar 5, 2019
  26. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Shoot me a PM and I'll put you on it.
     
  27. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    For issue 1, I did some tests, and it worked fine for me with a BoxCollider size of 2.5. Make sure you're changing the BoxCollider size on both your root Player GameObject and on his child Controller GameObject.

    On issue 2, the falling animation is meant to play when you're falling. It's designed so that if you play a turn animation and continue falling, the falling animation will continue playing once the turn completes, so it sounds like this is working the way it's meant to.

    For number 3, I might just flip your character's wall clinging sprites.
     
  28. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I did that. Well, I created a new project, increased the BoxCollider and the problem remained.

    The video is too big to load here, I will remove it from YouTube when you watch it.
    But my hero re-flaps his arms when I change direction in flight. I did not see the player’s running animation when it was in the air.
    You may not understand me. For example, if I want to make a Dash after a WallJump, the player will fly towards the wall because he is facing the wall. But I need it to fly away from the wall.
    ---
    I am not always sure that I can clearly explain...:)
     
  29. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Oh, I have another idea for the first issue: on your player's RexPhysics component, under the "Slopes" heading, is "Enable Detailed Slope Collision" checked? I was able to replicate the issue if I turned it off, but it goes away if it's turned on.
     
  30. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Ah, I see what you're saying with the dash. I'll look into fixing that -- I'm pretty sure I implemented a fix for this a while ago, but it seems to be bugged again, so I'll have to figure out why.
     
  31. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I have also turned on. This problem begins after increasing the height of the BoxCollider more than 2 units. Maybe it depends on the slope settings. It's weird that you have it all right...
     
  32. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    Resolved!
    In Rex Physics>Advanced>Raycast Amounts, it was necessary to increase the number of horizontal rays (up to 8).
    Thank you, I did not think to search in Rex Physics...
     
    Lars-Steenhoff likes this.
  33. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    I'm not sure if there's a Rex chat discord, but I'd love to join if so!
     
  34. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Not for the most part. I've been hosting one for the AI beta, but that's it.

    Speaking of, it's looking like the AI should be ready for a public release next week! Get pumped.
     
    Bagnol and Lars-Steenhoff like this.
  35. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Hey @BeeZee,i'm learning Unity and i created a player controller from scratch,so, can i use it in Rex ? in other words, can i use a player(actor) that has no Rex controller, no Rex states, no Rex physics, no Rex scripts at all, as the Player in Rex engine ? i was checking the code and there are some references to RexActor component, which again in my case i don't have, so i dont know if i just have to extend or remove/comment all the references, or it's too complicated and i have to use only a RexActor (= ?

    Thanks =D
     
  36. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Not really, no. If you remove all the stuff you're talking about, there's not much of Rex left; you've gotta use RexActor as your base, either way.
     
  37. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    I still do not understand about this problem. Maybe you did not understand me. If you press left or right during a fall, the fall animation starts playing from the beginning.
    When will the update? :з
     
  38. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I gotcha! It should be fixed in the upcoming update.

    The update's with Unity awaiting approval! I'm hoping for it to go live any day now.
     
  39. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Aaaaaand the AI update is live!



    Tutorial videos coming shortly.
     
  40. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's part 1 of the AI tutorials. This one covers the basics, and should get you up and running! I filmed a few other videos today, so I'll be editing and releasing those throughout the week.

     
    NaynayNeko, FunkyBuddha and CHEMAX3X like this.
  41. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    After updating the problems remained.
    Maybe I am doing something wrong, but this is still a problem.

    You have not managed to solve it yet? How can I solve this problems myself?
     
    Last edited: Mar 20, 2019
  42. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    The engine is great. But I found some bug in it: if I didn't put any turn animation to the controller, then it will not peroform normal.
    I saw the code:
    Code (CSharp):
    1. protected IEnumerator TurnCoroutine() //Turn() should be called rather than calling this directly
    2.         {
    3.             isTurning = true;
    4.             float duration = 0.0f;
    5.  
    6.             AnimationClip animation = (slots.physicsObject && slots.physicsObject.IsOnSurface()) ? turnAnimations.groundAnimation : turnAnimations.airAnimation;
    7.             if(StateID() == CrouchState.idString)
    8.             {
    9.                 animation = turnAnimations.crouchAnimation;
    10.             }
    11.  
    12.             if(!isOverridingAnimationInProgress && animation != null && slots.physicsObject && StateID() != LadderState.idString)
    13.             {
    14.                 duration = animation.length;
    15.                 slots.anim.Play(animation.name, 0, 0);
    16.             }
    17.  
    18.             while(slots.actor.timeStop.isTimeStopped) yield return null;
    19.             yield return new WaitForSeconds(duration);
    20.  
    21.             isTurning = false;
    22.             if(currentState && animation != null)
    23.             {
    24.                 currentState.PlayAnimationForSubstate();
    25.             }
    26.  
    27.          
    28.         }
    And I delete the animation != null then is run normal
    Code (CSharp):
    1. if(currentState)
    2.             {
    3.                 currentState.PlayAnimationForSubstate();
    4.             }
     
    BeeZee likes this.
  43. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    In the latest version, if you have *no* aerial turn animation slotted (on the RexController, under Turn Animations > Air Animation), then the falling animation won't start over when you change directions in the air. If you *do* have an aerial turn animation slotted, the falling animation will start over.

    The other things are coming soon -- hopefully in the next update; AI was my primary focus for this update, but I tried to sneak in some other small things where I could.
     
  44. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Looks like you're correct! Thanks for pointing this out. This is a new bug I accidentally introduced into this latest update while trying to fix another one. Thanks again for letting me know! I'll have it fixed in the next update.
     
  45. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Yes, I love new AI system. Small bugs are not the first priority.

    And today I found another bug when I use door. What I expect is that enter a door and could not come back. I think the door code add a bool variable to control whether it could be open will be better.( if use sceneloader SceneLoadType.EntranceOnly. it will occur some other problem...)
    This is my door script code:
    Code (CSharp):
    1. protected void CheckForEnter()
    2.         {
    3.             if( !couldOpen ) return;
    4.             if(!hasOpened)
    5.             {
    6.                 for(int i = actorsTouched.Count - 1; i >= 0; i --)
    7.                 {
    8.                     RexActor rexActor = actorsTouched[i].actor;
    9.                     if(rexActor != null)
    10.                     {
    11.                         if(actorSide == actorsTouched[i].side)
    12.                         {
    13.                             if((rexActor.slots.input && (rexActor.slots.input.verticalAxis == (int)pressDirectionVertical && rexActor.slots.input.horizontalAxis == (int)pressDirectionHorizontal)) || willOpenOnTouch)
    14.                             {
    15.                                 hasOpened = true;
    16.                                 Open(rexActor);
    17.                             }
    18.                         }
    19.                     }
    20.                 }
    21.             }
    22.         }
     
    Last edited: Mar 21, 2019
  46. Tee_Pee

    Tee_Pee

    Joined:
    Aug 18, 2013
    Posts:
    54
    Hello,

    Unfortunately I've run into a bit of a snag - adding the ladder prefab into my scene using Unity 2018.3.9f1 gives me the following warning:

    Any help would be appreciated.

    Best regards,
    Damir H.
     
  47. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Oh, thanks for pointing this out. I've run into this in a couple other places, as well -- basically, Unity's new prefab system doesn't like it when a script tries to destroy an object. In the case of the ladder, the ladder destroys its own tiles as you resize it -- so for example, if it's 5 tiles tall and you shrink it down to 3 tiles, it will destroy the top and bottom tile. This is something I plan to fix very soon. In the meantime, you might be able to work around it by:

    • Making sure the ladder you're resizing isn't a prefab
    • You might be able to resize it manually, simply by changing the size of its BoxCollider and adding or removing sprites yourself

    I think either of those should work.
     
  48. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    So you're looking for one-way doors, essentially?
     
  49. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's part 2 in the AI tutorial series!

     
    zengsadi233 likes this.
  50. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    @BeeZee

    So I updated the asset to my Rex Project, noticed some problems, my old enemy prefabs are not working properly anymore and showing warnings in the console, is there a way or a fix to this, as I watched the first new Ai tutorial, there are new stuff when creating an Ai compare to the old tutorial which is not available to watch in your yt channel, as I remember when creating enemies?

    Another one, my player prefab walk animation has a problem as well, when pressing from idle, walk animation doesn't work, when turning left and right, that's the only time the walk animation works. Then the problem starts all over again from idle. Will there be also some new tutorials for Rex aside from creating ai, like adding animations as all the old tutorials are not available in your yt channel anymore.

    Lastly, really appreciate your hard work on this asset, you did a great job on the new Ai system. congratulations.:cool: