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
    Hm? All the old tutorials should still be up -- I just checked, and they're all there and they're all public still.

    Old enemies won't work anymore, that's correct. The new AI system totally replaces the old one. All the enemy prefabs that come with the package have been remade with the new AI system, though, as well as everything in the demo levels, so those should be available as examples.

    The walking animation thing is a new bug that I introduced by mistake when trying to fix something else. There's a post about it a few posts up. Fortunately, it's easy to fix:

    Go to RexController.cs. You'll see this function:

    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.             AnimationClip animation = (slots.physicsObject && slots.physicsObject.IsOnSurface()) ? turnAnimations.groundAnimation : turnAnimations.airAnimation;
    6.             if(StateID() == CrouchState.idString)
    7.             {
    8.                 animation = turnAnimations.crouchAnimation;
    9.             }
    10.             if(!isOverridingAnimationInProgress && animation != null && slots.physicsObject && StateID() != LadderState.idString)
    11.             {
    12.                 duration = animation.length;
    13.                 slots.anim.Play(animation.name, 0, 0);
    14.             }
    15.             while(slots.actor.timeStop.isTimeStopped) yield return null;
    16.             yield return new WaitForSeconds(duration);
    17.             isTurning = false;
    18.             if(currentState && animation != null)
    19.             {
    20.                 currentState.PlayAnimationForSubstate();
    21.             }
    22.        
    23.         }
    And change the very bottom to:

    Code (CSharp):
    1. if(currentState)
    2.             {
    3.                 currentState.PlayAnimationForSubstate();
    4.             }
    My apologies for the mistake. I'll be releasing an update to fix it hopefully next week.
     
  2. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Yes, one way door
     
  3. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    I also meet this problem, what I solve in ladder script is add some code before DestroyImmediate:
    Code (CSharp):
    1.  
    2.                 #if UNITY_EDITOR
    3.                 if (UnityEditor.PrefabUtility.IsPartOfPrefabInstance(transform))
    4.                 {
    5.                     UnityEditor.PrefabUtility.UnpackPrefabInstance(gameObject, UnityEditor.PrefabUnpackMode.Completely, UnityEditor.InteractionMode.AutomatedAction);
    6.                 }
    7.                 DestroyImmediate(spriteRenderer.gameObject, true);
    8.                 #else
    9.                 Destry( spriteRenderer.gameObject );
    10.                 #endif
    11.  
    12.  
    And it could work for me. Or add code in Rexpalette script also could work maybe.
    Code (CSharp):
    1.  
    2. protected GameObject CreateAtPath(string prefabPath, bool isResource = true)
    3.     {
    4.         Object prefab = isResource ? Resources.Load(prefabPath) as Object : AssetDatabase.LoadAssetAtPath<Object>( prefabPath ) ;
    5.  
    6.         Vector3 position = (SceneView.lastActiveSceneView) ? SceneView.lastActiveSceneView.pivot : Vector3.zero;
    7.  
    8.         if(snapNumber != 0.0f)
    9.         {
    10.             position.x = (position.x - (position.x % snapNumber));
    11.             position.y = (position.y - (position.y % snapNumber));
    12.         }
    13.  
    14.         GameObject _gameObject = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
    15.         _gameObject.transform.position = position;
    16.         if (UnityEditor.PrefabUtility.IsPartOfPrefabInstance(_gameObject.transform))
    17.         {
    18.             UnityEditor.PrefabUtility.UnpackPrefabInstance(_gameObject, UnityEditor.PrefabUnpackMode.Completely, UnityEditor.InteractionMode.AutomatedAction);
    19.         }
    20.         ParentToActors(_gameObject);
    21.         Selection.activeObject = _gameObject;
    22.         Undo.RegisterCreatedObjectUndo(_gameObject, "Modify_" + prefabPath);
    23.         _gameObject.name = _gameObject.name.Split('(')[0];
    24.  
    25.         return _gameObject;
    26.     }
    27.  
    I think the reason why is that 2018.3 version add new prefab workflow, such as function
    PrefabUtility.DisconnectPrefabInstance is obsolete and PrefabUtility.InstantiatePrefab still a prefab not a gameobject.
     
    Last edited: Mar 22, 2019
  4. Tee_Pee

    Tee_Pee

    Joined:
    Aug 18, 2013
    Posts:
    54
    Hello,

    Yeah a bit of rummaging around the internet pointed me into the right direction. I ended up slightly modifying the ladder code to do this:

    Code (CSharp):
    1.             foreach(SpriteRenderer spriteRenderer in GetComponentsInChildren<SpriteRenderer>())
    2.             {
    3. #if UNITY_EDITOR
    4.                 if(PrefabUtility.IsPartOfAnyPrefab(gameObject))
    5.                 {
    6.                     PrefabUtility.UnpackPrefabInstance(gameObject,  PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction);
    7.                 }
    8.                
    9. #endif
    10.  
    11.                 DestroyImmediate(spriteRenderer.gameObject);
    12.             }
     
  5. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Cool, thanks for posting your solutions! I'll get the Prefab stuff updated in time for the next update.
     
  6. Tiler

    Tiler

    Joined:
    Mar 15, 2019
    Posts:
    1
    The group I'm working with picked up RexEngine around two weeks ago, and I've spent some time looking it over (its pretty cool, by the way; first time I've really had cause to delve into someone elses code extensively so I appreciate the relative order and clarity of it all) and I'm trying to figure the best way to implement a mechanic into the engine. The mechanic is something akin to one of those star portal things in smash bros if you've seen that; essentially a projectile that can catch whatever it hits, stops at either a set distance/time or when the user gives an input, and then at the user's direction, fire it out at something else, and probably do some mayham in the meanwhile. Intents are to use it for combat, as a way for the player to navigate, puzzles, and just whatever half baked idea comes up.

    I'm making an attempt to reuse as much of RexEngine's code as possible, so I've started with Attack.cs as a base for MeteorAttack, which so far just has the added functionality of imparting the actor's input reference to the projectile, so the user can stop it / fire what it's caught. The projectile itself has derived Projectile.cs component, but I've also given it RexActor component so I can resuse controller / state code instead of having to pack it all in the projectile-derived class (or, at the very least, have the projectile use the controller / state to determine what it does).

    Its sort of a weird solution in the service of having a thing both have controller/state data and also be used as a projectile via Attack.cs (since I can't make them interfaces without modifying a lot of the engine code, which I'm trying to avoid), so I was wondering if there was a better solution that I'd not keyed in on. My thoughts for firing other things like enemy actors was to just attatch some state data or otherwise put them in purgatory and temporarily disable and replace them with a projectile-style object that just uses their sprite data, to avoid having to worry too much upfront about their state or AI or fiddling too much with stuff like ContactDamage. I'd tried to see if I could essentially force a state on an actor but that didn't seem to be the proper route, as far as I could ascertain. In any case there seems to be a need for a bit of a handshake between objects and I'm wondering what the best way to get it all to flow properly would be.

    On a last unrelated note, I was getting Unity errors from depreciated commands (2018.3), namely PrefabUtility.DisconnectPrefabInstance(gameObject) and PrefabUtility.CreateEmptyPrefab(). In the former I just commented it out; I hadn't really seen that command ever used before so I'm not sure what its purpose had been, but the objects in scene seemed to be unpacked entirely without the command anyways. For the latter, I replaced instances of it it and the next line with PrefabUtility.SaveAsPrefabAssetAndConnect(newObject, localPath, InteractionMode.AutomatedAction); I've messed around with things in the meantime and I haven't noticed any misbehavior, but yet again, I'm not entirely sure.

    Thanks for making RexEngine, by the by.
     
  7. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya, thanks for picking up Rex! That means a lot to me.

    This seems like a pretty complex thing. I'm hoping I'm properly understanding what you're trying to do. For setting the state of an actor, you can call the "SetState" method on its RexController, and pass it a reference to the state you want it to have. Off the top of my head, it seems like having both a Projectile *and* a RexActor component might be overkill -- I could potentially see those canceling each other out for certain things, as they'll both be trying to manipulate the actor in different ways. My gut says that I'd probably just give it Projectile, and then add your own additional movement options to Projectile from there. You can call on the Projectile's RexPhysics component using the MoveX(), MoveY(), and StopAllMovement() methods for when you want the projectile to move or stop moving, and you could override the Projectile's UpdateMovement() method to set how it moves each frame.

    Thanks for noting the PrefabUtility stuff! Unity did indeed break that with 2018.3 and their new prefab functionality. I'm working on a fix for the next Rex update.
     
  8. smika78x

    smika78x

    Joined:
    Dec 22, 2013
    Posts:
    16
    @BeeZee just stumbled over this little bit older post :D
    any news about music per area and not interrupting between scenes?
     
  9. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Not yet -- been primarily focused on the enemy AI update. The next update is going to add some new features to that, and then, we'll see!
     
    smika78x and Lars-Steenhoff like this.
  10. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Hey @BeeZee i think i found a bug, related with the water controller, when the player enter in water and then comes out to land, it keeps all the water behaviors for example the jump and movement speed in my case, which are the only things i changed between both land and water controllers, here is an example:

    waterController.gif
    And here the settings, i just checked this option

    1.jpg

    and i have both controllers already set

    2.jpg

    Also, how can i enable and disable the water controller with code? like if it was an ability.

    And one suggestion: to have an option for a "default behavior" of the land controller while entering in water, like killing the player, or for example like in many games the player by default floats in the water or dies till the swim/dive ability is enabled.

    Thanks =D
     
  11. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Ok so i fixed this problem overriding the falling speed in the land controller, but now i'm facing 2 more issues, the first one:

    The player uses the Water movement speed (which is slower) instead of the land movement speed, till the player enters the water and comes out:

    waterController1.gif

    The second one is if the player jumps to the water, you can see this weird jump behavior (i wasn't pressing the jump button in the water)

    waterController3.gif
     
  12. Pixelkeyblade18

    Pixelkeyblade18

    Joined:
    Jan 18, 2019
    Posts:
    3
    Hi, just got Rex Engine. It's really amazing. I'm trying to implement the ledge hang but it only works 50% of the time. Is there a way to make the ledge detection a tiny bit more forgiving so the player has an easier time hanging on a ledge? Thanks and great job.
     
    Lars-Steenhoff likes this.
  13. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    2019-02-22 12-41-40.gif

    Hello, I found one problem about one-way platform. if there are two one-way platform close, it will like the gif, player will fall down.

    I think maybe some problem in RexPhysics.CheckVerticalCollisions function:
    Code (CSharp):
    1.  
    2. //This prevents you from walking off a one-way platform, holding left or right to be back inside it as you fall, and clipping back up on top of it
    3.             if(didCollide && raycastHit.collider.gameObject.layer == LayerMask.NameToLayer("PassThroughBottom"))
    4.             {
    5.                 if(!isTranslatingDirectly)
    6.                 {
    7.                     didCollide = IsRaycastHitOutsideCollider(raycastHit);
    8.                 }
    9.             }
    10.  
    if raycast hit inside collider then didCollide will always false and player will fall down.
     
  14. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for getting Rex! I appreciate it.

    Hm... that one's actually new to me. I've tested out the ledge hang pretty extensively and I've never had issues with it. It could be something in your settings. Can you .zip up your project and PM it to me? I can take a look.
     
  15. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Ah, yeah. That block of code you have there is specifically designed to *prevent* walking off of one one-way platform and onto another, because that can cause visual issues if you walk off of one platform and then immediately push the direction to go back onto it. Feel free to comment it out if you don't mind that, though!
     
  16. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    The first thing I'd like to test is: if you start a fresh Rex project and test out the demo scenes, are you seeing the same behavior? There's some water in Demo_8 that should work for testing.
     
  17. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    @BeeZee
    I ask about this warning on the console before, you said just ignore it. It's been a few months now and multiple Rex update, is there a way to get rid of this warning to not show up in the console during play mode?

    RexWarning.png
     
  18. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I don't think that particular one is a Rex error. Unity will sometimes throw kind of frivolous warnings based on textures or materials in your project, and this looks like one of those. I've gotten rid of all the Rex-related warnings I've been able to find.
     
  19. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Boss AI!

     
    CHEMAX3X and Bagnol like this.
  20. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Awesome, thanks for sharing, i just noticed one thing =O, min 12:45/12:46, is it normal that transition between animations? or is there a way to fix it?

    Love that boss battle music btw =D
     
  21. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I had to splice two bits of video together there. Nothing is actually happening in Unity.
     
    CHEMAX3X likes this.
  22. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    The new version of Rex is out! This one has some really cool new features:

    • Moving Platforms got a big overhaul, and can now be set to have multiple waypoints!
    • There are some new AI tools to play with, including the ability to have enemies react in certain ways based on whether or not they're facing the player (or other objects).
    • The Bounce action now lets you go bounce lower or higher based on how long you hold the button down
     
    Yinyamina and CHEMAX3X like this.
  23. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    Seems like the updated code you did haven't fixed the problem,
    "(currentState && !(animation == null && animation == turnAnimations.airAnimation))"

    I still have to apply what you advised earlier to make my player turn animation work.
     
    BeeZee likes this.
  24. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    That's weird -- I just checked, and I have the fix on my computer but it seems to have not been uploaded with the rest of 1.51. Thanks for the letting me know! I just submitted a hotfix that should be live shortly.
     
  25. Eireenevan

    Eireenevan

    Joined:
    Jan 7, 2018
    Posts:
    3
    Hello,

    I have a display problem when I launch the demo.
    At the background, I have a band on the left and a band on the right.
    I'm using Unity 2018.3.11f1 and Rex Engine V1.51.
    In the project there is only the Rex Engine.
    Do you have an idea to correct that ?

    RexEngine Problem.PNG
     
    CHEMAX3X likes this.
  26. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    I had the same issue once, you could change the aspect ratio from free aspect to 16:9 or make the canvas background bigger =O
     
    BeeZee likes this.
  27. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    CHEMAX3X is correct (thanks for fielding that, CHEMAX3X!) Unity does that when there's no background rendering below any of the cameras. The Rex demo is made for 16:9, so setting your Game window to a 16:9 aspect ratio will solve it (or you can just extend the background to cover any other dimensions, if you'd rather use those!)
     
    CHEMAX3X likes this.
  28. Eireenevan

    Eireenevan

    Joined:
    Jan 7, 2018
    Posts:
    3
    OK thank you ! It's work.
     
    CHEMAX3X likes this.
  29. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I would like to change my control mappings to different buttons, I'm using InControl and I'm wondering where to change it.

    Thanks
     
  30. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's an integration guide:
    http://www.skytyrannosaur.com/rex-engine-incontrol-integration/

    At the bottom, you'll see a section called "Changing Inputs" which has an explanation for how to change button mappings.
     
    Lars-Steenhoff likes this.
  31. FunkyBuddha

    FunkyBuddha

    Joined:
    Aug 17, 2017
    Posts:
    75
    @BeeZee

    Just wondering for optimization purposes, is there a feature in Rex where we can activate and deactivate certain gameobjects, say when it's in a certain distance from the player?
     
  32. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    RexPhysics has an option to only do physics calculations when the actor is on-camera (and RexPhysics is the biggest hog in terms of processing.) That's the only one as of now.
     
  33. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Now that AI is done, it's time for some other stuff! Pushable objects are officially underway.
     
    hodgepodge2022, Bagnol and CHEMAX3X like this.
  34. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's Booster pushing a tree stump (using temp art for the time being):

     
  35. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Further progress on pushing:

     
  36. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    There seems to be one bug with the yellow bullet status indicator icon. when I complete the demo game, and the credits roll, the icon is still showing.
     
  37. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Can you make a video of how to install this?
    I don't know where everything needs to go. thanks
     
  38. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    When I'm walking on stairs the player can't attack, can you add this ability?
     
  39. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I think there is one bug in the "ground pound"

    Wen I have horizontal movement disabled, it can still move to the left. To the right is blocked as expected.
     
  40. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    There's a "Stair Climbing" checkbox on the Attack component under "Can Initiate From." Checking that will allow an attack to be performed while you're climbing stairs.
     
    Lars-Steenhoff likes this.
  41. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I wasn't able to replicate this, but I did discover that, if you have residual acceleration/deceleration on your character from before, the Ground Pound doesn't stop that. Thanks -- I've fixed it for the next update.
     
    Lars-Steenhoff likes this.
  42. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Yes I have residual acceleration/deceleration on the player, that may have been the reason. Thanks for fixing.
     
  43. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    Heyow !! hey @BeeZee, quick question, how can i activate a melee attack's collider at the end of an animation ? i have some issues, let me explain:

    Let's say you have an enemy which for their melee attack, first it raises their arms, and then move the arms down to hit the player, now, all this is an attack, so the box collider will be activated at the beginning which is when the arms are raised, if the player is next to the enemy at this point, it will be damaged, cuz of the box collider being activated(don't know if im clear ._.).The same for example if you have an enemy who uses spikes or electricity, where the beginning of the attack is the enemy charging their power for a few frames to then actually attack.

    I saw an option to manually activate the collider, but how can i do this =O ?

    Thanks.
     
  44. IXTLIA

    IXTLIA

    Joined:
    Feb 9, 2019
    Posts:
    1
    I picked up Rex Engine about a month ago and I am really enjoying it. I have 2 quick questions.

    1. Can I assign the Ground Pound ability to a different button press -- namely to one of the sub weapon buttons?

    2. Enemy.cs doesn't have the "Will launch on death" bool option that DemoEnemy.cs does. I like the cartoony effect, but I can't figure out how to add it to new enemies I create through the Rex Palette.
     
  45. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Wow! Cool! I very need push ability!
     
  46. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Hi, I found some bug in PatrolMovement , you could see in this gif. Enemy will turn if there is a ladder in front of them.

    2019-02-22 12-41-40.gif

    And if PatrolMovement could have some options that could turn when contact with other enemy.
     
  47. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    You can enable or disable the collider in the AnimationClip for the attack itself.
     
    CHEMAX3X likes this.
  48. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for letting me know. I've fixed this for the next version.
     
  49. CHEMAX3X

    CHEMAX3X

    Joined:
    Jan 8, 2018
    Posts:
    265
    .... Ohh yeah, that's right i forgot that part =P...

    But still, could you explain me for what is this option in the attack script?, i mean by the text looks obvious, but if i toggle it on and off, i don't see any difference

    option.png
     
  50. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    "Will Auto Enable Collider" makes the collider enable itself immediately, as soon as the attack starts. If you turn it off, the collider won't enable itself on its own -- it will wait for you to manually enable it, either via the AnimationClip or through code.
     
    CHEMAX3X likes this.