Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

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

  1. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Okay, so I did forget to disable it (my bad), but I can't seem to get it to play when the enemy is defeated, and I'm not getting any errors either...
     
  2. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 Without knowing more it's going to be a little tricky to say what exactly is happening.
    • Can you expand the enemy's prefab in the hierarchy while in play mode and kill the enemy, and see if the particle prefab enables briefly? If not then something's probably gone wrong in the code somewhere.
    • Is the particles prefab set to 0,0,0 on all 3 axes? Or close to it if you manually adjusted it.
    • If you can see the particles prefab become enabled in the hierarchy in play mode, can you hit the pause button while the particles are enabled, switch to the Scene tab, select the particles prefab, and press the F key to focus on it and make sure it's in the right location? I've had particles play off in random places if I've forgotten to zero out the transform.
    • If it's in the correct location and being enabled but you still can't see it, can you see the particles play in other circumstances? I've had some particles from the Asset Store set to the "TransparentFX" Layer at the top of the inspector by default that makes them invisible in some cases. Also maybe check the Sorting Layer of the Renderer section of the Particle System component. A lot of particles are set to the Default Sorting Layer out of the box and need to be changed once you start using Foreground and Background etc.
     
    PhantomFox128 likes this.
  3. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    This seems to be what's happening. I didn't see it get enabled at all when testing.

    EDIT: I take it back. I think I may have just had the delay up way too long. I set the Destroy on Death to Never and it played after a couple of seconds. But now I'm noticing that if the enemy gets destroyed, the particle goes with it even before it plays or is playing (I set the delay to a lower value and it gets destroyed in the middle of the animation if the enemy goes as well). So I think I don't want the enemy to destroy itself then? How would I go about this?

    On that note: if I wanted it set up so that certain enemies (specifically all non-boss enemies) respawn after leaving their location and coming back (like in old-school games), would I actually want the enemy to destroy itself at all?

    And real quick: How is the Particle Delay measured? I thought it was in seconds, but before I had it set to a flat 1 and it didn't spawn until later.

    EDIT2: Okay, I think I have the right code to disable the Sprite Renderer, but I'm not entirely sure where to put it. I've already tried a few places and nothing seems to be working.
     
    Last edited: Mar 21, 2020
  4. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's a tutorial on a long-requested new feature!

     
  5. JRBlake

    JRBlake

    Joined:
    Jul 17, 2017
    Posts:
    4
    Thank you for the excellent update. I really appreciate the video walkthrough of the multiple MP pools feature as well. :)

    If I may ask, are there any plans for implementing any shield block mechanics? Not sure if that's been brought up by anyone yet, but either way I'd love to throw my interest for it into the mix. I was thinking maybe something like they did in Shadowcrypt, directional and only effective while the shield is selected as the active sub-"weapon"?:


    (mechanic fully displayed at 2:15, in case the video fails to load at the specified timestamp)
     
    Lars-Steenhoff likes this.
  6. vvelasco

    vvelasco

    Joined:
    Sep 21, 2015
    Posts:
    25
    Hi guys.
    I'm new to the Rex Engine. First of all, great tool. It has almost everything I need for my new game.
    I searched on the youtube channel and some tutorials but I don't see a tilemap editor. Just wondering if I'm missing this feature or if you're using unity tilemap system (which is great already)

    I was also wondering if you have a plan to implement a ledge climb like this


    Best
     
    Last edited: Mar 16, 2020
  7. Tom_Bombadil_

    Tom_Bombadil_

    Joined:
    Aug 6, 2018
    Posts:
    46
    Glad to see this getting updated. New features are always super welcome. The scene loaders loading scenes is something I never knew I needed but now that I have it it’s absolutely great.
     
    BeeZee likes this.
  8. daddyshome

    daddyshome

    Joined:
    Oct 26, 2019
    Posts:
    5
    hello everyone.

    let me start by saying i'm still learning unity.

    my character is clipping into the ground for a few frames before hitting his melee attack when he is moving.

    i recorded it and put it in slow motion and it looks like the character is switching to his standing state before moving into the attack.



    i changed the collision of the default character. is there a collision somewhere i missed that i need to fix?
    this only happens when triggering the attack when character is moving. standing attack works fine.
    does anyone have ideas on how i can correct this?
     
    Last edited: Mar 18, 2020
  9. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Hello,

    Good question -- not new to unity, but I'm new to the RexEngine. I was going to submit a question of my own, but I thought I'd speak to your question first.

    Unity uses two things to tell itself where an object (player) should be on the screen: colliders and sprite pivot point. First, check to see if the 2D box collider collider for the attack. Is it smaller than the 2D box collider for the idle/walk animation? If so, this is the culprit.

    If it's not the collider, check the pivot point of the sprite. Go to your "Project" folder, and find where the sprites are for the attack. Select one of them. In the inspector, check the pivot point. Is it different than the pivot point of sprites used in the other animations? If so, this is the culprit. Make sure the pivot points are in the same location for animations to look seamless.

    Hope this helps!
     
  10. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Hello,

    New to the RexEngine, not new to unity. Been developing dexterstardust.com using Adventure Creator. For the sequel, I wanted to do a genre swap, and create an adventure platformer. RexEngine has been awesome to throw myself into, after fumbling around with Corgi. The community here seems awesome as well!

    My questions are related:

    1. When I create a new enemy, the enemy is destroyed by being bounced on. I check all the appropriate boxes. It can be destroyed with a bounce, but each time the player bounces on the enemy it damages the player. It damages the enemy, but also the player. I cannot for the life of me figure out why. The DemoEnemies don't damage my player when bounced on, but the new Enemy does. Is this a bug?

    2. When the player bounces on the enemy, I want it to play a knockback animation, which I have assigned and enabled. However, when the Player bounces on the enemy it doesn't knockback. I saw a previous post about squishing an enemy, but I'm not a fan of squishing pixel art. I like to use pixel perfect animations for all animations and particle effects, so a knockback animation is ideal. Any thoughts how to enable this? Should it be working?

    Again, awesome engine. Any comments would be appreciated. Having fun figuring it out!
     
  11. daddyshome

    daddyshome

    Joined:
    Oct 26, 2019
    Posts:
    5
    thanks for the reply.
    the attack adds a collider for the weapon but doesn't change the idle/walk collider. which is the reason i am confused.

    i checked the pivot points of all the sprite frames. they are all 0.5, 0.5.
     
  12. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Hmmm... OK. One more thing to check. How about the sprite sizes? Are all of them the same pixel sizes? For example, if you have two sprites that you want to make part of the same animation, yet one is 32X32 and the other 32x48... well, the pivot may be the same, but that second sprite is taller and will make it seem like that frame suddenly drops. Is this the issue? What are the sprite sizes for the idle/walk animations, and what are the sprite sizes for the attack animations?
     
  13. daddyshome

    daddyshome

    Joined:
    Oct 26, 2019
    Posts:
    5
    attacking stops movement in my game. the attacking and running animations both work fine independently. it's the transition from running to standing attack. the file resolutions are probably marginally different but i used offsets in animator to correct this.
     
  14. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    So sorry... I'm stumped. Without looking at the project itself, it's difficult to say exactly what the issue is. Sorry I can't be of more help. Maybe another user has an idea. It honestly sounds like a Unity issue and not a RexEngine issue. It's difficult to say though. Again, I wish I could help more.
     
    Last edited: Mar 20, 2020
  15. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Do you notice anything scrubbing through the animation clips when the game isn't playing yet? To add on to what's been said above, I think the potential culprits could be:

    • The sprites themselves having empty space around them
    • Pivots and offsets to the sprites
    • The BoxCollider changing size (Be sure to check both the BoxCollider on the root of your player *and* on his child RexController object!)
    • The BoxCollider's offset changing
    • The child positioning of your SpriteRenderer and/or any of the other child objects the SpriteRenderer is parented to, including SpriteHolder and JitterHolder

    I think the best way to troubleshoot would be: hit Play to test your game, trigger the issue with the sprite pushing into the ground, and hit Pause in the Editor just as the issue happens. From there, you can select your player, and drill down into its child objects to check the positioning of each one. You'll also be able to see the green outline of your BoxColliders, so combined, that should hopefully show you what's not lining up properly.
     
    jeremyfryc likes this.
  16. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    1. Hm... I've never seen that happen before; it definitely shouldn't be happening. Off the top of my head, is the BoxCollider the same size on the root of your player's GameObject and on their RexController object? If they're different sizes, I could potentially see one of them triggering first, and damaging your player on the collision, before the other one triggers the bounce.

    2. Knockback doesn't trigger on bouncing, since knockback is designed to be horizontal, and a bounce happens on the vertical axis. If you want, though, you can accomplish it with a minor bit of scripting. RexActor has the following virtual method:

    Code (CSharp):
    1. public virtual void OnBouncedOn(Collider2D col = null)
    If you write a script to extend RexActor, you can then do the following:

    Code (CSharp):
    1. public override void OnBouncedOn(Collider2D col = null)
    2. {
    3.     slots.controller.Knockback(Direction.Horizontal.Right);
    4. }
    (The "Knockback" function call up there can be called from anywhere to trigger knockback on a character. You can also pass it Direction.Horizontal.Left if you want it to get knocked to the left; if you really want to get fancy, you can use the "col" value that gets passed in, which is the collider of the character that *caused* the knockback (i.e. your player, bouncing on the enemy), and use its positioning to determine what direction to knock the enemy back.)

    Hope that helps!
     
  17. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Here's a tutorial on the new Quick Scene Switching feature!

     
    jeremyfryc likes this.
  18. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Thank you so much for responding. Very much appreciated. And your new video is great. I didn't notice that new feature! So cool. About my previous questions/issues -- I was successful with number 2, but no luck with number 1:

    1. Bouncing on newly created enemies still results in damaging my player. I have made sure that all BoxColliders2D on both the player and the enemy are the same size. This is actually one of the first things I checked, I tried to make them bigger, then smaller, then the same size -- no change. I also swapped my player for Booster, enabled his bounce state, and when he bounces on the newly created enemy, he does damage, but he also gets damaged as well. Again, this happens when I create a new enemy from the RexPalette. Even when I don't change anything on that enemy. But when I play my player in the demo levels, with the DemoEmemies, the player can bounce on them without receiving damage. Take a look at a video of this happening with RexPalette enemies and my player here: https://imgur.com/a/XOPhBPC

    In the video, the enemy takes three hits and on the third hit dies. On the first two hits, the player is damaged (you can see this by flashing), although the player's knockback animation does not play. Even so, the player deals damage as well. On the third hit, the player bounces on the enemy, and the enemy dies without damaging the player. All this leads me to think that it's the enemy and not the player. But again, I could be wrong. Any help or further suggestions would be appreciated. I'm in Unity 2019.3.6f1 with the latest RexEngine build.

    2. The code you provided worked perfectly and, while I'm no coder, it helps me understand how your code works a bit better. You can actually see the result in the above video. What I wanted was the enemy to play a knockback animation when getting bounced on without moving horizontally, and it works! When the player bounces on the enemy, it plays a little compressed body animation with sparks flying out. Thanks for that.

    Anyways, I hope to hear back about number 1 and if anyone else has seen this issue, please let me know. Thanks!
     
  19. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Does your enemy have their "Can Bounce On" checkbox ticked?
     
  20. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Yessir! Enemies have "Can Bounce On" checkboxes ticked and Player has a Bounce state enabled.
     
  21. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Hm... definitely sounds like a bug. Thanks for bringing it to my attention! I'll have to do some tests. I'll keep you posted!
     
  22. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    So, I figured out that if you reduce the enemy's HP to 1 (that is ,1 bounce) it doesn't damage the player when bounced on and it dies in 1 bounce. So, there must be something in the code telling it to damage the player if the enemy's HP is above 1. I hope this helps a bit. Another piece to the puzzle. I guess. Thank you for investigating.
     
  23. JRBlake

    JRBlake

    Joined:
    Jul 17, 2017
    Posts:
    4
    Has anyone here implemented any sort of shield mechanics within/alongside this engine? By shield I mean like "sword and shield" not "Sonic the Hedgehog shield bubble."

    Also, @BeeZee might you please update us on whether there are any plans/progress on an inventory system or at least an integration with some other inventory system asset? It would be such a key feature for a modern take on this retro style, yet I don't see it mentioned here for over a year now. Just ringing that bell again, in case it might rekindle interest or focus on that. Thanks.
     
    andreiagmu likes this.
  24. tirkaroKujo

    tirkaroKujo

    Joined:
    Jul 10, 2017
    Posts:
    10
    I'm not sure how to make dialogue portraits show up in the Dialogue Popup script; There's a field for the portrait number, but no actual space to list the dialogue portraits; and evidently just slapping an NPC script onto it doesn't work out.
     
  25. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    179
    You need to set the portraits (and the dialogue text) in the NPC script (from the NPC gameobject), instead of using the DialoguePopup script.
    This video explains it better:

     
  26. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    179
    Maybe I understand now, you want to use the DialoguePopup, to display an arbitrary dialogue (with character portrait) without needing an NPC, is that it? Or it's because you need the dialogue to autoshow, or show it via OnTriggerEnter2D?

    You could try extending the NPC class to add/copy the features from DialoguePopup (willAutoShow bool variable, OnTriggerEnter2D that calls ShowDialogue()), it depends on what you want to do exactly.
     
    Last edited: Mar 25, 2020
    BeeZee likes this.
  27. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    179
    Rucksack is an inventory system that became open source not long ago.
    An integration between Rucksack and Rex Engine would be very interesting!
    https://github.com/devdogio/Rucksack

    By the way, Inventory Pro and Quest System Pro (from the same developers of Rucksack), are also open source now. ;)
     
    Last edited: Mar 25, 2020
    BeeZee and JRBlake like this.
  28. daddyshome

    daddyshome

    Joined:
    Oct 26, 2019
    Posts:
    5
    thank you for your reply. SpriteHolder was where that one weird frame was coming from. i changed the animation and collider offsets to match SpriteHolder and it works fine now.



    i have one more question: how am i communicating to unity where on a collision box determines weather a jump was successful? my environment collision box is hitting the side of my player collision box but then the player slides up on top of the platform anyway. also if i change player direction by a ledge my character slides up on the ledge. thank you again.
     
  29. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    Hi, been using Rex Engine for a while and am trying to convert our scenes to use Unity Universal Render Pipeline and 2D lights. We've been following instructions closely and am able to see everything fine in the editor-- but gameplay is blank. So far this is Rex Level specific. Any suggestions, non-support, or quirks we should know? A setting somewhere easy to miss?

    Here's a cap from a newly generated Rex level. Basically all materials are now using "Sprite-Lit Default" from URP. Editor shows properly and reflects live input actions, while gameplay shows blank.

    rex_URP_example.jpg
     
  30. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I've been considering it. It's too early to say anything definite, but this might be a good time to open the floor up to you guys. What types of features would you like to see in an inventory system? What types of situations would you like to use it in?
     
  31. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    It looks like the wall by your character isn't perfectly vertical -- in the video, it looks like it's at a slight diagonal, going up and to the right. That can often confuse the engine into thinking it's meant to be a sloped floor, instead, so making the wall a perfectly vertical 90 degrees will probably fix that. (And to answer the first part of the question, a jump is considered successful when the very bottom of your collider touches a floor.)
     
  32. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    That's a new one for me! I'm unfortunately not that familiar with the URP. I do, however, often see that behavior out of Unity's camera system when specific camera settings are in place -- usually on the Camera component's Clear Flags dropdown. During gameplay, in the Project window, you should see a "Cameras" object under DontDestroyOnLoad, with multiple child objects, each with a Camera component for a different layer. Does changing the settings on those cameras help? Maybe toggling various cameras on and off? (Rex also doesn't really use any unique camera stuff for rendering -- it's all standard Unity cameras -- so if those ideas don't work, it's also possible that the answer is elsewhere on the Unity forums!)
     
  33. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    Thanks for the response... As it turns out, the URP camera settings are quite different from the default. I've been trying my best to experiment with different options-- the key seems to be somewhere between choosing Render Type: Overlay vs Base, and correct culling masks. I CAN now get the gameplay to appear, with some caveats. Unfortunately changing some of the settings in the Camera prefabs appear not to hold and are generated anew when game is played and DontDestroyOnLoad is generated (specifically noticing culling masks settings). Research and trials continue on the Unity side.

    URP_cameras.jpg

    Building a level with the new 2D lights system gets some really nice results, it's something we definitely would like to move forward with. Curious if you ever give URP a go yourself and see how you feel on it affecting cameras with Rex.
     
  34. jeremyfryc

    jeremyfryc

    Joined:
    Mar 11, 2014
    Posts:
    95
    Hello and thank you for asking about about inventory! An inventory system would certainly be a great idea, but I can totally understand how complex it would be. I developed a game with Adventure Creator, which has a great inventory system for adventure games, but Adventure Creator has no platforming mechanics or 2D physics to speak of, that's why I'm using Rex. Again, Rex is awesome. Thank you thank you thank you.

    That said, here are some use cases for an inventory system that I would greatly appreciate:
    • Scene specific inventory system: this could be used to collect and hold collectables. Kind of like collecting the letters "KONG" in Donkey Kong Country. The inventory system could be assigned to only one scene or groups of scenes. If a save system were implemented down the road, these scene-specific collectables (and # of lives), could be retained in the save file. This is why I call it an inventory system, since it needs to be called upon on demand. Of course, this may be achievable with another kind of menu system.
    • Adventure Style Inventory System: items to use on certain triggers/hotspots. To explain: the player's collider enters a trigger/hotspot, you press a button, it plays an animation and picks up the item. This item then appears in a menu. You then travel to a different trigger/hotspot, and you can open your inventory menu, select that item and use it to play another player animation (or scene animation), resulting in some kind of change to the scene or NPC. Of course, we're dealing with logic and variables here, but this would open the door for a ton of gameplay.
    • Weapons inventory: This is something that Rex kind of already has, but I think a lot of people would want a beautiful pause menu to open that you can move around with your gamepad and select a new weapon or item, which, in turn, changes the attack animation of the character.
    These are my hopes and wishes! Keep up the good work. Thanks for asking.
     
    PhantomFox128, andreiagmu and BeeZee like this.
  35. Tom_Bombadil_

    Tom_Bombadil_

    Joined:
    Aug 6, 2018
    Posts:
    46
    One again back with another questions: I have been working with the engine a little bit and there are a couple of custom features I have implemented in and it’s working out really well. However, as of right now then functionality is hard coded into the character script which I made to replace the booster script. It seems to me however it would be more efficient to build them in as new Rex States. Is are any tutorials or documentations for building custom Rex States? I was trying to dig through the scripts themselves but I was having a little trouble and I was wondering if you could help me out.
     
  36. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    C-C-C-Combo question!

    Read docs, watched video, and am very pleased with the ability and ease of setup for combo attacks via Rex Engine. One key limitation noticed is that any attack in a combo must fully complete its animation cycle. Whereas in an ideal combo chain, an attack animation would be interrupted at a specific frame/time and then start the next attack in the chain:

    Rex_combo_example.jpg

    Definitely understood this may sound like an advanced feature for your engine. Seeing as you have other attributes featuring frame timeouts, cancels, initiates, and allowances referenced to other animations, I’m asking if you think the above is possible in some form in the existing architecture, editing code, or perhaps a viable feature of the future.
     
    andreiagmu likes this.
  37. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    At the bottom of the Attack script, there's an option for Cooldown Time, which I believe prevents any input for a specified amount of time. You can try setting it so that the cooldown ends before the animation does. It should allow for you to cancel the current attack animation and transition to the next attack, otherwise the current attack animation will just play through and go back to your idle. You might need to play around with it to get the timing right, although if you want to test it out and see if it's what you're looking for, you could set it to a really low number and mash the attack button.

    Hope this helps!
     
    Last edited: Apr 1, 2020
    Edco, spaceJASE and andreiagmu like this.
  38. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I don't have a guide for this at the moment, but this is something I'd really like to get set up. It's a (potentially) very complex topic. Up for being my guinea pig? We can go over some stuff one piece at a time in the forum here, and once we've got it in a good place, I'll consolidate it (most likely a into a written guide, because I think it's better to have code-related stuff in writing where it's searchable!)
     
    andreiagmu likes this.
  39. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    179
    I just noticed that the TimeShift prefab (in Resources -> Gimmicks) and the two Castlevania-inspired enemies (Batdactyl and ZombieDino) seem to have a missing script. I tested reimporting RexEngine in a new Unity project, to be sure.

    @BeeZee Can you check this? Is something important missing?
     
  40. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    Thanks much @PhantomFox128 , I fiddled with those numbers earlier, so this time switched to extremes to whittle down and start making sense of the cutoffs. Works fine for 2 combos, but glitches start occurring for 3 combos and above, especially with low values. Can't quite figure out the math but there appears to be a conflict with the overall "Frames Before Timeout" setting and the last combo in the chain "Cooldown Time." In my testing the actions do not replicate the video tutorial results, and the combo is continually interrupted by restarting the combo, never reaching third/final chain and thus ignoring cooldown time. Experiments continue.

    @BeeZee , there was maybe a Rex Engine update that changed a small detail:

    -- in the combo tutorial video, the Attack Script has the entry for "Cooldown Frames," but it now reads "Cooldown Time." What unit of time is this exactly? Seconds?

    -- additionally, for the Combo Chain (Script), the "Frames Before Timeout," is that literal frames of the Actor animation or a reference to overall gameplay frames per second? (presumed later)
     
  41. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    Combo Update: Tore some stuff out, started over, adjusted some animations.

    Mostly working :) tho you can see a small glitch on the 1-2 if you watch closely, cooldown related vs input I'm guessing. Frames Before Timeout offers a pretty wide window to combo at a slower pace, which while not intentional is not so bad. (lower values were not playing nice).

    attack1a.gif
     
  42. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    I went through the Rex demo again and I noticed there was an animation for "DeathSmoke" that seemed to be attached to the Tricerabot, but it looks like it doesn't get used. Is that actually the case?
     
  43. Scalisco

    Scalisco

    Joined:
    Feb 2, 2014
    Posts:
    20
    Hi all! I'm in love with Rex! I do have a few questions if anyone can help out.

    I'm trying to make physics like Donkey Kong Country. I want to make a roll ability like Diddy's cartwheel and I'm having trouble doing these mechanics for it:
    • If you roll off a ledge, gravity is still obeyed, so you will start to fall
    • Let's you jump as long as you're rolling, so you can roll off a ledge and jump to save yourself.
    • Damage an enemy/collider that is able to be damaged on the side you're hitting it from.
    • If you damage an enemy by rolling you gain momentum - makes you run faster
    I'd like to know what the best approach to creating this would be. I started trying to use the dash ability, which works well as long as you're on flat ground and there are no enemies.

    Any advice would be appreciated, thanks!
     
  44. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    This will definitely require a bit of custom code. There are a lot of individual pieces here, so this might get a bit complex. Here are some tips to get started:

    • I'd definitely make your own script for your player that overrides RexActor so you can house your custom code
    • RexActor has a virtual method called OnStateChanged, which gets automatically called when the RexActor changes to a new state, like dashing or jumping. It also has an OnStateEntered and OnStateExited method, which are called when a state begins and ends, respectively. All of those are automatically passed the state that's being called, so you can use that to determine if the state is a dash or a jump. Here's an example:
    Code (CSharp):
    1. if(newState.id == DashState.idString)
    2. {
    3.      //Do dash-related stuff here
    4. }
    5.  
    6. if(newState.id == JumpState.idString)
    7. {
    8.      //Do jump-related stuff here
    9. }
    • You can make your player temporarily invincible by setting invincibility.isShieldInvincibilityActive = true;
    • You can use OnTriggerEnter on either your player or your enemy to determine when a collision is happening, and check against the player's slots.controller.currentState.id to see if the player is dashing. If so, you can call the Damage() function on the enemy.
    • Both DashState and MovingState have a "speed" property that you can alter at will to give your player a speed boost.
     
  45. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Looks like it's attached to the Tricerabot's death particle. There's an animation in place here of a smoke cloud puffing up, but the layering seems to be wonky, so it's not displaying for some reason. It's been so long that I don't recall the specific details, but this is a pretty cool-looking effect! Thanks for letting me know. I may try to get it working in an update.
     
    PhantomFox128 likes this.
  46. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Is this your own artwork? These animations are super cool.

    Cooldown Time is indeed in seconds. Frames used to go by FixedUpdate, which is good for physics but doesn't play nicely with input-related things, so Cooldown Time in seconds should be more precise.

    ... looking at this now, it looks like the framesBeforeTimeout on ComboChain still uses FixedUpdate, so it looks like I didn't update that one when I updated Attack. I'm going to investigate this more -- off the top of my head, I think this is something I should change.
     
    spaceJASE likes this.
  47. Edco

    Edco

    Joined:
    Dec 6, 2013
    Posts:
    16
    Yes, thank you :)

    Thanks for looking into it. Will gladly test if/when future update addresses.
     
  48. Tom_Bombadil_

    Tom_Bombadil_

    Joined:
    Aug 6, 2018
    Posts:
    46
    @BeeZee I would not be terrible opposed to being a guinea pig on this one. I have tried disecting other states without much luck.

    Also I am having another issues with stairs. I know this should be simple and self explanatory but I can not seem to find anywhere to says how to set them up. The Stair layer seems to do absolutely nothing and there are no stairs in the demo to take a look at.

    Edit: With more testing I have discovered that you can move up slopes as long as they are terrain even without the stairclimbing state over all kinda confused on how this works.

    Edit2: I was able to track down that block pushing bug I was talking about earlier in a fresh download of the demo. All you have to do to recreate it is drop a pushable block into any scene then change its collider size to 2.5. The first time you hit a wall it will jump to the top to the wall.
     
    Last edited: Apr 4, 2020
  49. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    437
    Been playing around with the system for a bit and noticing some crucial features that seem to be missing, so i went ahead and added them in.

    Landing particles - The included landing particle system for the LandingState only allows one particle to play when landing, it doesn't offer the ability to detect what tag/surface you landed on or what direction the player is facing, which changes where and how the landing particle is played.

    What I added:

    - Detect landing tags (unlimited)
    - Play landing particle per tag (unlimited)
    - Check direction of player (checks facing direction and plays particle in proper direction)
    - Offsets for particle play based on current facing direction, for each particle/tag
    - The ability to turn on and off tag checks per tag/particle
    - Custom tag/string inputs for tag checks via inspector
    - Debug (returns back what tag you landed on if true)

    The code:

    Code (CSharp):
    1.  
    2.  
    3.         [System.Serializable]
    4.         public struct FloorParts {
    5.  
    6.             public bool checkTag;
    7.             public string floorTag;
    8.             public RexPool landTagPart;
    9.  
    10.             [Space]
    11.  
    12.             [Tooltip("If Landing Particle Pool is slotted, this lets you adjust the positioning of the landing particle.")]
    13.             public Vector2 particleOffset_Right;
    14.  
    15.             [Tooltip("If Landing Particle Pool is slotted, this lets you adjust the positioning of the landing particle.")]
    16.             public Vector2 particleOffset_Left;
    17.  
    18.         }//FloorParts
    19.  
    20.         [Header("Cust Land Particle")]
    21.  
    22.         [Space]
    23.  
    24.         public bool useDebug;
    25.         public bool useDirCheck;
    26.         public bool checkFloorTag;
    27.         public FloorParts[] floorParts;
    28.  
    29.         [Header("Auto")]
    30.  
    31.         [Space]
    32.  
    33.         public int tempInt;
    34.  
    35. protected void SpawnLandingParticle() {
    36.  
    37.             GameObject particle = null;
    38.  
    39.             tempInt = -1;
    40.  
    41.             if(!checkFloorTag){
    42.  
    43.                 particle = landingParticlePool.Spawn();
    44.      
    45.                 ParentHelper.Parent(particle, ParentHelper.ParentObject.Particles);
    46.  
    47.                 particle.transform.position = new Vector3(landingParticlePool.transform.position.x + particleOffset.x, landingParticlePool.transform.position.y + particleOffset.y, 0.0f);
    48.  
    49.                 int verticalDirection = (controller.GravityScaleMultiplier() >= 0) ? 1 : -1;
    50.                 particle.transform.localScale = new Vector3((int)controller.direction.horizontal, verticalDirection, 0.0f);
    51.  
    52.                 particle.GetComponent<RexParticle>().Play();
    53.  
    54.             //!checkFloorTag
    55.             } else {
    56.      
    57.                 for (int i = 0; i < floorParts.Length; ++i) {
    58.      
    59.                     if(controller.slots.physicsObject.GetSurfaceTag() == floorParts[i].floorTag){
    60.          
    61.                         if(floorParts[i].checkTag){
    62.                  
    63.                             tempInt = i;
    64.              
    65.                         //checkTag
    66.                         } else {
    67.              
    68.                             if(useDebug){
    69.                  
    70.                                 Debug.Log("Tag Detected but CheckTag is off" + " " + tempInt.ToString());
    71.              
    72.                             }//useDebug
    73.                  
    74.                         }//checkTag
    75.              
    76.                     }//GetSurfaceTag() == floorParts[i].floorTag
    77.      
    78.                 }//for i floorParts
    79.      
    80.                 if(tempInt > -1){
    81.      
    82.                     if(floorParts[tempInt].landTagPart != null){
    83.      
    84.                         particle = floorParts[tempInt].landTagPart.Spawn();
    85.              
    86.                         ParentHelper.Parent(particle, ParentHelper.ParentObject.Particles);
    87.  
    88.                         if(!useDirCheck){
    89.  
    90.                             particle.transform.position = new Vector3(floorParts[tempInt].landTagPart.transform.position.x + particleOffset.x, floorParts[tempInt].landTagPart.transform.position.y + particleOffset.y, 0.0f);
    91.  
    92.                         //!useDirCheck
    93.                         } else {
    94.              
    95.                             if(controller.direction.horizontal == Direction.Horizontal.Left){
    96.                  
    97.                                 particle.transform.position = new Vector3(floorParts[tempInt].landTagPart.transform.position.x + floorParts[tempInt].particleOffset_Left.x, floorParts[tempInt].landTagPart.transform.position.y + floorParts[tempInt].particleOffset_Left.y, 0.0f);
    98.                      
    99.                                 if(useDebug){
    100.                      
    101.                                     Debug.Log("Particle Left");
    102.                          
    103.                                 }//useDebug
    104.                  
    105.                             }//direction = Left
    106.                  
    107.                             if(controller.direction.horizontal == Direction.Horizontal.Right){
    108.                  
    109.                                 particle.transform.position = new Vector3(floorParts[tempInt].landTagPart.transform.position.x + floorParts[tempInt].particleOffset_Right.x, floorParts[tempInt].landTagPart.transform.position.y + floorParts[tempInt].particleOffset_Right.y, 0.0f);
    110.                      
    111.                                 if(useDebug){
    112.                      
    113.                                     Debug.Log("Particle Right");
    114.                          
    115.                                 }//useDebug
    116.                  
    117.                             }//direction = Right
    118.              
    119.                         }//!useDirCheck
    120.              
    121.                         int verticalDirection = (controller.GravityScaleMultiplier() >= 0) ? 1 : -1;
    122.                         particle.transform.localScale = new Vector3((int)controller.direction.horizontal, verticalDirection, 0.0f);
    123.  
    124.                         particle.GetComponent<RexParticle>().Play();
    125.              
    126.                         if(useDebug){
    127.                  
    128.                             Debug.Log("Tag Detected " + floorParts[tempInt].floorTag);
    129.              
    130.                         }//useDebug
    131.          
    132.                     }//landTagPart != null
    133.          
    134.                 //tempInt > -1
    135.                 } else {
    136.      
    137.                     if(useDebug){
    138.          
    139.                         Debug.Log("No tags detected");
    140.              
    141.                     }//useDebug
    142.  
    143.                 }//tempInt > -1
    144.      
    145.             }//!checkFloorTag
    146.  
    147.         }//SpawnLandingParticle

    Something to note is that this does not conflict with the previous script setup, so you can either use this edit or the original script settings without conflicts.

    Movement Footsteps - While the MovingState allows you to set what footstep plays per tag walked over, it does not give you the option to play particles based on a tag, i.e dust, water, etc.

    What I added:

    - Detect movement tags (unlimited)
    - Play movement particle per tag (unlimited)
    - Check direction of player (checks facing direction and plays particle in proper direction)
    - Offsets for particle play based on current facing direction, for each particle/tag
    - The ability to turn on and off tag checks per tag/particle

    The code:

    Code (CSharp):
    1.      
    2.  
    3. [System.Serializable]
    4.         public class FootstepSoundWithTag
    5.         {
    6.             public string surfaceTag = "Terrain";
    7.             public AudioClip sound;
    8.        
    9.             [Space]
    10.        
    11.             public bool useDirCheck;
    12.             public bool showPart;
    13.             public RexPool stepPart;
    14.        
    15.             [Space]
    16.        
    17.             [Tooltip("If Landing Particle Pool is slotted, this lets you adjust the positioning of the landing particle.")]
    18.             public Vector2 particleOffset_Right;
    19.  
    20.             [Tooltip("If Landing Particle Pool is slotted, this lets you adjust the positioning of the landing particle.")]
    21.             public Vector2 particleOffset_Left;
    22.        
    23.             [Space]
    24.        
    25.             public Vector2 particleOffset_Reg;
    26.        
    27.        
    28.         }
    29.  
    30.  

    And then inside CheckFootstepsSound() right underneath PlaySoundIfOnCamera, you put:

    Code (CSharp):
    1.                      
    2.  
    3. if(footstepSounds.sounds[i].showPart){
    4.                    
    5.       PlayStepPart(i);
    6.                    
    7. }//showPart
    8.  
    9.  

    Which is pretty much the same thing as landing particle edit but with a few adjustments:

    Code (CSharp):
    1.         private void PlayStepPart(int tempInt){
    2.    
    3.             GameObject particle = null;
    4.            
    5.                 if(tempInt > -1){
    6.            
    7.                     if(footstepSounds.sounds[tempInt].stepPart != null){
    8.            
    9.                         particle = footstepSounds.sounds[tempInt].stepPart.Spawn();
    10.                    
    11.                         ParentHelper.Parent(particle, ParentHelper.ParentObject.Particles);
    12.  
    13.                         if(!footstepSounds.sounds[tempInt].useDirCheck){
    14.  
    15.                             particle.transform.position = new Vector3(footstepSounds.sounds[tempInt].stepPart.transform.position.x + footstepSounds.sounds[tempInt].particleOffset_Reg.x, footstepSounds.sounds[tempInt].stepPart.transform.position.y + footstepSounds.sounds[tempInt].particleOffset_Reg.y, 0.0f);
    16.  
    17.                         //!useDirCheck
    18.                         } else {
    19.                    
    20.                             if(controller.direction.horizontal == Direction.Horizontal.Left){
    21.                        
    22.                                 particle.transform.position = new Vector3(footstepSounds.sounds[tempInt].stepPart.transform.position.x + footstepSounds.sounds[tempInt].particleOffset_Left.x, footstepSounds.sounds[tempInt].stepPart.transform.position.y + footstepSounds.sounds[tempInt].particleOffset_Left.y, 0.0f);
    23.                            
    24.                                 if(useDebug){
    25.                            
    26.                                     Debug.Log("Particle Left");
    27.                                
    28.                                 }//useDebug
    29.                        
    30.                             }//direction = Left
    31.                        
    32.                             if(controller.direction.horizontal == Direction.Horizontal.Right){
    33.                        
    34.                                 particle.transform.position = new Vector3(footstepSounds.sounds[tempInt].stepPart.transform.position.x + footstepSounds.sounds[tempInt].particleOffset_Right.x, footstepSounds.sounds[tempInt].stepPart.transform.position.y + footstepSounds.sounds[tempInt].particleOffset_Right.y, 0.0f);
    35.                            
    36.                                 if(useDebug){
    37.                            
    38.                                     Debug.Log("Particle Right");
    39.                                
    40.                                 }//useDebug
    41.                        
    42.                             }//direction = Right
    43.                    
    44.                         }//!useDirCheck
    45.                    
    46.                         int verticalDirection = (controller.GravityScaleMultiplier() >= 0) ? 1 : -1;
    47.                         particle.transform.localScale = new Vector3((int)controller.direction.horizontal, verticalDirection, 0.0f);
    48.  
    49.                         particle.GetComponent<RexParticle>().Play();
    50.                    
    51.                         if(useDebug){
    52.                        
    53.                             Debug.Log("Tag Detected " + footstepSounds.sounds[tempInt].surfaceTag);
    54.                    
    55.                         }//useDebug
    56.                
    57.                     }//stepPart != null
    58.                
    59.                 //tempInt > -1
    60.                 } else {
    61.            
    62.                     if(useDebug){
    63.                
    64.                         Debug.Log("No tags detected");
    65.                    
    66.                     }//useDebug
    67.  
    68.                 }//tempInt > -1
    69.         }
    70.  
    71.  


    Conslusion:

    These are things I definitely recommend adding as core features, with the ability to either use or not use them, like how i made the edits.

    I hope this can help others who are looking for the same features :)
     
    Last edited: Apr 4, 2020
  50. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    How do I set up an enemy so that only a certain part of their body deals contact damage? I got a big enemy that I want the player to be able to run underneath them without getting hit, but I can't figure out how to set that up.

    Quick Edit: I'm running into a more serious problem: I set up an enemy to jump at random intervals and set the animations accordingly, but it looks like it keeps reverting back and forth to its idle animation for a split second in between all the other animations, giving it this really weird looking jitter. I've reset the Jump component multiple times and even gave it a simple one frame jump animation (with no starting or crest animations) and it still happens. Only way to fix is to get rid of all the animations on the Jump script.
     
    Last edited: Apr 6, 2020