Search Unity

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

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

  1. hoyoyo80

    hoyoyo80

    Joined:
    Jan 31, 2018
    Posts:
    58
    Ok.Thanks
     
  2. jemchicomac

    jemchicomac

    Joined:
    Jan 2, 2018
    Posts:
    10
    Hi! I'm unable to make things working when player dies after touching my custom spikes.

    First of all, let's discuss how I created the Spikes:

    • A tileset with Tilemap Collider 2d + Composite Collider 2d, just for creating "Deadly things" with an arbritriary shape not limited to square tiles
    • A "Contact Damage Script" from Rex Engine attached to the tileset. I believe this should be enough enabling "Deadly things" into Rex



    Well, once my hero touches a "Deadly thing" death seems to be properly triggered but these errors appears (after a fade to white):



    Under this situation, as you can see in the capture, I tried to follow the suggestion of using the 2017 suggestion of using a spriteless checkpoint, but things doesn't seem to work. If I enable on Build Settings "Demo_1" player comes back to live in "Demo_1" and everything works, but this is not the intended behaviour that would be coming to "celesteLikeScene" at the checkpoint instead.

    In addition, the Box2D error seems to be related on how I'm configuring the "Deadly things" tileset.

    I've tried to find my way via DataManager.cs or even RexSceneManager.cs without any luck.

    I need your help!

    Thanks!
     

    Attached Files:

  3. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya, I tested this out with a fresh install of 2019.2.15, and I'm not seeing the errors. I specifically looked at the lines of code you mentioned, and they seem to be okay. I did notice that Unity popped up a message saying that the project used obsolete API's, and asking me to update them, when I first imported the Rex project. I said "no" there, because that usually means Unity is going to make changes to your project's code, so if you saw the same message and said "yes," that could account for the issue. At any rate, I'd try a fresh copy of your project in 2019.2.15, and you should be okay.
     
  4. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    You'll want your spikes to have a BoxCollider2D, component, as opposed to a TilemapCollider2D; that should fix the first issue. The second half of your issue appears to be that you need to add the Demo_1 scene to your Build Settings under File > Build Settings > Add Open Scenes (while you have Demo_1 open.)

    For your checkpoint issue, it sounds like the checkpoint isn't triggering in your celesteLikeScene. I'd try one of the existing checkpoints with sprites first to ensure that you're able to properly walk into it and trigger it. If you can confirm that's working, then you can try removing the sprites from there.
     
  5. jemchicomac

    jemchicomac

    Joined:
    Jan 2, 2018
    Posts:
    10
    Hi! Thanks for the answer, I've p
    Thanks, man!

    I just played around with the checkpoint and everything is fine now! The hero dies and comes back to the checkpoint.

    However, I'm still getting the BoxCollider2D error. Just for the shake of clarity I do want TilemapCollider2D and CompositeCollider2D for defining the "deadly zones" and NOT BoxCollider2d, but seems that is REX the one trying to find a BoxCollider2D in my tileset. This is what Unity says:

    MissingComponentException: There is no 'BoxCollider2D' attached to the "Deadly" game object, but a script is trying to access it.
    You probably need to add a BoxCollider2D to the game object "Deadly". Or your script needs to check if the component is attached before using it.
    RexMath.GetColliderOverlapCenter (UnityEngine.BoxCollider2D col1, UnityEngine.BoxCollider2D col2) (at Assets/RexEngine/Scripts/RexEngine/_Helpers/RexMath.cs:26)
    HitSparkManager.CreateHitSpark (UnityEngine.BoxCollider2D col1, UnityEngine.BoxCollider2D col2, System.Boolean wasTargetDamaged, System.Int32 targetHealth) (at Assets/RexEngine/Scripts/RexEngine/_Managers/HitSparkManager.cs:44)
    RexEngine.RexActor.Damage (System.Int32 amount, System.Boolean willCauseKnockback, BattleEnums+DamageType damageType, UnityEngine.Collider2D col) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:596)
    RexEngine.RexActor.ProcessCollision (UnityEngine.Collider2D col, RexEngine.RexObject+CollisionType type) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1086)
    RexEngine.RexActor.OnTriggerEnter2D (UnityEngine.Collider2D col) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1136)
     
  6. hoyoyo80

    hoyoyo80

    Joined:
    Jan 31, 2018
    Posts:
    58
    Hi. Starting with a new project does the trick. But can you advice on how to do future Unity update?Since for me, it broke during the update. No project yet,just the Rex asset. Thanks
     
  7. LUSHI

    LUSHI

    Joined:
    Jul 3, 2012
    Posts:
    13
    @BeeZee

    I know your busy with other things but I have a question for you and an issue..... I think lol.

    -issue-
    I noticed that if you jump into your water while hitting a combo the combo will continue until it's finished before going into the swimming animation and stopping you from being able to attack. i checked the code t(at quick glance so I may have missed it) but I didn't see anything to cancel your attack and go straight to the swim animation. Is there such a function?

    -question-
    And I was wondering if there was a way to be able to use an ability while swimming (same as flying) I would like to be able to shoot a projectile while I'm swimming is there away for that to happen as well?

    I wanted to ask before I start editing your code just Incase you have already thought of it.

    Thanks for your time.
     
  8. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Hey, so I dunno if this is a Rex Engine thing or a Unity thing, but I've been replacing some of my animations (originally they were all placeholder sketches) and they don't seem to want to play properly. I initially took the new images and dragged them on top of the old ones in the animator window and they would play, but my idle sprite (the main one I set in the sprite holder) would stay on top of it. I messed with it a bit and now it's not playing at all. So, I don't know what to do. Should I restart all the animation stuff?
     
  9. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya. Rex is generally going to want a BoxCollider2D for damaging collisions. In part, it needs that to help it do things like play hit sparks and to determine where your character should be knocked back to on the collision. It's *maybe* possible to look at those lines of code you highlighted, if you want, and replace the BoxCollider2D references with more generic Collider2D references, but that could also potentially cause problems. I think the safest way is going to be to just use BoxCollider2D's for your spikes. (You can still use tilemaps or whatever else for the art, if you'd like, and just use BoxCollider2D's for the collisions.)
     
  10. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    As a rule, I'd keep all of your custom assets *outside* of the RexEngine folder, because anything inside that folder is fair game to be updated. I'd also make a backup of your project first. If you do an update and it tells you something broke, you can try again, and Unity should pop up a window when you do the update with checkboxes that allow you to select or unselect specific assets, so you can un-check specific things that broke.

    As far as the exact issue that happened to you, my suspicion is that it was related to Unity asking to update obsolete API's (although it's hard to verify without seeing it.) I'd just make sure never to say "Yes" when it asks that.
     
  11. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    There are a couple pieces of code that should help you with that. You can put the code on your RexActor (I'd make a new script for your player that extends RexActor.)

    Code (CSharp):
    1.     protected override void OnControllerChanged(RexController _newController, RexController previousController)
    2. {
    3.  
    4. }
    The above function gets called whenever the player's controller is changed (such as when they change to their Swimming controller, or their Default non-swimming controller.) If you store references to your controllers, you can use this to determine which controller is being changed to, and act on that.

    Code (CSharp):
    1. if(currentAttack != null)
    2.             {
    3.                 currentAttack.Cancel();
    4.             }
    The above code will stop any attacks that are currently active.

    You can also call isEnabled on any of those attacks and set that equal to true or false to enable or disable the attack. You can call that in OnControllerChanged to toggle specific land or water attacks.

    The Booster.cs file, which is the demo character's script that extends RexActor, also has some pretty good examples of all of this, if you're interested!
     
    spaceJASE likes this.
  12. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Oh man, this one! This is a pretty common Unity issue that manifests whenever the SpriteRenderer isn't on the root level of your GameObject (which it shouldn't be.) What happens is, Unity's Animator window is finicky, and when you're setting up a new AnimationClip and dragging sprites into the Animator window, that will sometimes *add a brand-new SpriteRenderer object to your player* instead of just adding a new frame to your AnimationClip. Then, when you play your game, that new SpriteRenderer can show up on top of your existing one, and since it's not being animated, it just covers up your "correct" SpriteRenderer. I'd take a look at your player's prefab and look for extra SpriteRenderers, and remove them if you find them. Once that's fixed, you can sort of develop a feel for when this is happening as you create AnimationClips. You'll want to double-check that the Record button is activated when you drag sprites onto it, and that your correct SpriteRenderer is selected as you're doing it. I also just tend to watch the Hierarchy tab out of the corner of my eye as I build animations to make sure no new SpriteRenderer objects are getting added.
     
    spaceJASE and PhantomFox128 like this.
  13. LUSHI

    LUSHI

    Joined:
    Jul 3, 2012
    Posts:
    13
    Fantastic I will give this a shot when I get home I should have thought about the Booster.cs because that's what I'm using to help me get rope system working.

    Thank you again.
     
  14. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Thank you!

    Couple other things I thought of: is there any way to set jumping to have the player keep facing the same direction even if they press back? Like if you jump and press the opposite direction you're facing, you'll move back, but you keep facing forward.
    Also wondering if there's any way to add a sort of slow down slide if the player turns while running. Just thought those would be kinda neat.

    EDIT: Another quick question: What's the difference between the box collider on the main game object and the one on the controllers?

    EDIT 2: Sorry for all the questions. I keep running into things. I just got a bunch particle effects from the asset store and I tried slotting one of the splash effects into Rex, but instead if gives me these errors:

    "NullReferenceException: Object reference not set to an instance of an object
    RexEngine.Water.GenerateEnterSplash (UnityEngine.Vector2 location, UnityEngine.Transform actor) (at Assets/RexEngine/Scripts/RexEngine/_Actors/Water.cs:28)"

    "NullReferenceException: Object reference not set to an instance of an object
    RexEngine.Water.GenerateExitSplash (UnityEngine.Vector2 location, UnityEngine.Transform actor) (at Assets/RexEngine/Scripts/RexEngine/_Actors/Water.cs:43)"

    "MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object."

    EDIT 3: Piggybacking off the above, it seems to be doing this for multiple particle effects. I just tried swapping out the landing particles with an asset one and I'm getting roughly the same kind of errors.
     
    Last edited: Dec 18, 2019
  15. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    For jumping: you can try the Freeze Horizontal Movement checkbox on JumpState.cs. That will lock your jump in whatever direction the jump started, like how the early Castlevania games do it. Attacks also have an option under Actions Allowed During Attack > Turning which will let you continue to move, but not turn around, while the attack is active.

    For the box colliders, the collider on your RexController should be the same size as the collider on your root object. They're just there to detect collisions for different scripts; the one on the root detects collisions for the player itself, while the one on the RexController detects them for your various abilities. For example, if you have the ladder climbing state, then the collider on your RexController is responsible for detecting when you're touching ladders and such.

    Your particle errors are probably because your particle's GameObject is missing the RexParticle component. You should be able to grab RexParticle.cs from your Library and drag it onto your particle GameObjects. (RexParticle handles spawning and despawning particle systems or animations at the appropriate time, which is why it needs to be there.) Once the RexParticle component is on your particle GameObjects, that should let them work.
     
    PhantomFox128 likes this.
  16. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Okay, so I managed to get splashes working, but I'm running into issues with the landing dust particles. What I'm doing is opening the LandingParticlePool object and replacing the prefab with the one I have (the RexParticle script is on it). When doing that and then starting the game however, I'm immediately given an error:

    " Assertion failed on expression: 'IsNormalized(normal, 0.001f)' "

    Jumping and then hitting the ground also gives the MissingReferenceException error. Oddly enough, it's still technically playing, but only one instance of the particle spawns (instead multiple like it should) and it doesn't move. I'm assuming this one might take a bit more to set up since it's tied to a character, but I'm not sure how to go about it.
     
  17. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 I just went through and replaced the landing particle prefab with some random non-Rex particle system that I'd attached a Rex Particle component to and it's working just fine for me. It even plays the sound effect and child particles that are attached every time.

    I haven't come across the Assertion failed error, but a bit of googling indicates it's a fairly tricky error that's been randomly happening since at least 2016. Have you tried a different particle system prefab?
     
    BeeZee likes this.
  18. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Just tried it with a different one and yeah, it's doing the same thing. Also worth mentioning, my landing animation doesn't transition to the idle animation upon hitting the ground, it seems to play through and then get stuck on the last frame (I only have a single placeholder sprite for that, so it's hard to tell if it's actually playing or not). Replacing the original Rex Particle fixes it, but that's hardly an ideal solution. EDIT: Disregard that, it seems to be playing normally now.

    I don't know if this'll help much, but this the asset I'm using: https://assetstore.unity.com/packages/vfx/particles/cartoon-fx-pack-4-23634
     
    Last edited: Dec 22, 2019
  19. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    If you click on the Missing Reference Exception error, and look below it, does it say where it's coming from? That might give us a clue what's going on.
     
  20. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Recently I use adventureCreator and I think the RexEngine if the data and engine could be separate would be better for update the engine. Such as use ScriptedObject for new game and use a wizard create the new folder for the new game.
     
  21. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Here's the full console log:

    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    RexPool.Spawn () (at Assets/RexEngine/Scripts/RexEngine/_Pooling/RexPool.cs:33)
    RexEngine.LandingState.SpawnLandingParticle () (at Assets/RexEngine/Scripts/RexEngine/_States/LandingState.cs:115)
    RexEngine.LandingState+<LandingCoroutine>d__12.MoveNext () (at Assets/RexEngine/Scripts/RexEngine/_States/LandingState.cs:101)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    RexEngine.LandingState:OnBegin() (at Assets/RexEngine/Scripts/RexEngine/_States/LandingState.cs:57)
    RexEngine.RexController:SetState(RexState, Boolean) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexController.cs:280)
    RexEngine.RexState:Begin(Boolean) (at Assets/RexEngine/Scripts/RexEngine/_States/RexState.cs:70)
    RexEngine.RexController:ApplyPhysicsObjectFlags() (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexController.cs:661)
    RexEngine.RexController:FixedUpdate() (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexController.cs:211)

    Quick Edit: This error seems to only show when it doesn't play the effect whatsoever. Upon testing, it seems to not play the effect the first time I run the game after opening it up in Unity (character also gets stuck in the landing animation). However, everytime I test afterwards, it plays the one particle and the error doesn't show. It keeps doing that until I close out Unity and reopen the project.
    UPDATE: Just tried this again and now it's doing it everytime I test. It seems almost random.

    On a semi-related note, I also imported this particle asset (https://assetstore.unity.com/packages/vfx/particles/epic-toon-fx-57772) and got a bunch of notifications that a bunch of RexEngine scripts were using obsolete APIs. I didn't update any of them and everything still works so far, but I figured I should let you know.
     
    Last edited: Dec 28, 2019
  22. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 JMO's particle prefabs generally have an automatic self-destruct/destroy script attached. Have you tried removing /disabling that component? Maybe the JMO script is destroying the prefab before it can be returned to the pool by Rex?
     
  23. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Just tried disabling it. It's not giving the MissingReferenceException error, but it still plays the one particle. Also still getting that weird "Assertion failed" error.
     
  24. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 I'm not seeing the Assertion Failed error in your pasted console log, is there more info in the console log specifically when that error is selected?
     
  25. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    The error I posted was for the MissingReferenceException. The Assertion Failed error is its own error and doesn't give much info, just the " Assertion failed on expression: 'IsNormalized(normal, 0.001f)' "

    UPDATE: So, I just tried testing it with a few other particles and oddly enough, it doesn't happen with all of them. A few that I tried aren't giving me any errors and are actually playing normally (although they're stuck behind the player, but that's probably easily fixable). Others though, (like the puff cloud I want to use for the landing dust) do give the Assertion failed error and sometimes the MissingReferenceException error. It honestly seems to be kind of random, although now I'm thinking it could possibly be an issue with a the particle effects themselves that I am using.
     
  26. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    As far as the particles being stuck behind the player, that's most likely the particle being set to Local space and not World space, which is a setting on the Particle System itself.

    The main error you're getting sounds like the particle is destroying itself (Bagnol mentioned this earlier, so I'm just echoing him on that one.) Rex's pooling system tries to recycle particles, so if any of them get destroyed prematurely, that can cause issues.

    One other thing you could test that might give us some idea of what's going on: in LandingState.cs, there's a function on line 113 called "SpawnLandingParticle()". This function is responsible for playing the particle when you land. Right now, that function is designed to use the RexParticle and RexPool systems, but if you wanted, you could comment out all of the existing stuff and just have it directly call the custom particles you're using.
     
    Bagnol and PhantomFox128 like this.
  27. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Oddly enough, setting it to World space has seemed to outright fix everything. Particles are now playing the way they should and I'm not getting any errors! Thanks guys!
     
    Bagnol likes this.
  28. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Okay, a few other things I got. I set up the DamagedSparkPool with a particle effect, but it only plays in the middle of the level and not where the actual hit is taking place. How would I fix this? Also, what does the NotDamagedSparkPool do?
    And piggybacking off of that, is there a way to set different effects depending on what's being hit instead of using the same effect for everything?

    The (hopefully) final thing I have for particles is that I'm going for a sort of Smash Bros. style explosion upon the player being defeated, so instead of a death animation, their sprite would disappear into this epic firework show of particles. I'm having some issues with this though. I've set the actor to "Destroy on Death" which does make the sprite disappear, but then I'm given the MissingReferenceException error and the level doesn't reload. Specifically:

    "MissingReferenceException: The object of type 'RexActor' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    RexEngine.RexSceneManager.LoadSceneWithFadeOut (System.String level, UnityEngine.Color fadeColor, System.Boolean willStartFreshFade, System.Boolean _willNextSceneFadeIn, ScreenFade+FadeDuration _duration) (at Assets/RexEngine/Scripts/RexEngine/_Managers/RexSceneManager.cs:121)
    RexEngine.GameManager+<PlayerDeathCoroutine>d__20.MoveNext () (at Assets/RexEngine/Scripts/RexEngine/_Managers/GameManager.cs:268)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17) "

    I'm assuming it's because the actor technically doesn't exist anymore?
    Also, the particle effect I have slotted doesn't play and I'm getting this (StarBurst2D is the name of the effect):

    "Coroutine 'PlayCoroutine' couldn't be started because the the game object 'StarBurst2D' is inactive!
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    RexParticle: Play() (at Assets/RexEngine/Scripts/RexEngine/_Components/RexParticle.cs:15)
    RexEngine.RexActor:SetDeathParameters() (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:893)
    RexEngine.RexActor: Damage(Int32, Boolean, DamageType, Collider2D) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:546)
    RexEngine.RexActor: ProcessCollision(Collider2D, CollisionType) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1111)
    RexEngine.RexActor:OnTriggerEnter2D(Collider2D) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1161) "

    The last particle question I have: is there a way to set multiple particle effects to one thing?

    Last question I have for now. Probably not specifically related to Rex, but what would be the best way to add some ambient music tracks (on top of the regular music) for a level? Right now I just have a game object with a few audio sources slotted in but I'm wondering if there's a better way to do it, since Rex has music in the level settings.
     
    Last edited: Jan 4, 2020
  29. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128
    1. I'm not having any issues with custom HitSparks playing correctly - have you checked the particle system's Transform Position values? I think you'll generally want the X,Y,Z Positions to be close to 0,0,0 (depending on the particles). I've also noticed that my HitSparks particles were playing in the middle of the screen when I didn't have the Rex Particles script attached to them. An easy thing to miss.
    2. The NotDamagedSparkPool I believe is the particles that play when the character is hit by an enemy/projectile/etc. but takes 0 damage - which could be enemies that simply do 0 damage but still "hit" the player, or the player being hit while the Shield powerup is active.
    3. I don't think you want the player to be destroyed on death, only your enemies. I believe destroying the player will stop them from being respawned.
    4. The Smash Bros. style death will probably require a bit of script extension/modification. If the characters can only die at the edge of the screen, you could possibly just use the death particles for the fireworks and maybe disable the sprite renderer and delay the death process if necessary so the particles can play through. If characters can die on screen as well though, you'll probably have to modify how deaths are handled to distinguish between an on-screen death and a Smash Bros. death. There are multiple ways you can go about it, but I think they'll all require some script modification/extension.
    5. Is the StarBurst2D coroutine error happening after the player is destroyed? That might be the issue.
    6. You might need to clarify what specifically you mean by setting multiple particle effects to one thing. If you're looking to have multiple effects play at the same time every time, you could just create extra particle effects as children to the main one, but I've had some weird results with child particles not behaving correctly when Rex flips them to be facing left - which I don't believe is unique to Rex. If you're not looking to have them all just play at once though, with a little script modification/extension it's not too difficult to add essentially as many particles as you want to happen whenever you want them to - but exactly how you achieve that will depend on how confident you are in modifying/adding to Rex's scripts.
    7. As for the music, again it comes down to specifically what you want to achieve. As far as I'm aware, Rex's handling of music is fairly simple, but can be easily bypassed if necessary. There are some robust audio management assets on the Asset Store, but depending on what you're after, some basic collision triggers could do the trick if you just want to turn specific tracks on and off at specific locations. I haven't looked into Rex's level audio too much though myself.
     
    PhantomFox128 likes this.
  30. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    Okay, not having the Rex Particle attached seems to be what was causing the position issue.

    I was actually planning on doing a Smash style explosion if the player falls into a pit, but the one I was initially thinking of was a kind that happens on screen when the player runs out of health. The easiest example I can think of are Hero's KO moves in Smash Ultimate.
    (Forums did not like the gif I put in, so here's a video that has some of what I'm talking about:

    Specifically looking at 1:24, 1:30, 1:43 and 2:05. Sorry for the video link, I really couldn't find anything better.)
    I was also thinking of doing something like that for enemies. For example, in Kirby, when you defeat an enemy, their sprite sort of disappears and it plays a little "explosion" in their place.

    As for multiple particles, part of it ties into the above. For a Smash style explosion, I figured it would be easier to have multiple particle effects go off at once.
    For the other part, I was thinking more along the lines of having a different HitSpark particle play depending on what is being hit. For example, if the player were to hit something with a sword, it would make sense to have a bunch of sparks fly out, but if they were to hit something that's not hard/sturdy (like a slime monster for example) or punch something, I figured it would be more unique to have a different effect play for those sort of occasions.
     
    Last edited: Jan 5, 2020
  31. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    In that case you'll probably need a way to differentiate cause of death/damage type. Rex appears to have traces of an elemental damage system in the code - specifically references to poison damage in the RexActor and BattleEnums scripts, but I couldn't really find anywhere that it was actually used (though I didn't look very hard because I'd only discovered it half way through implementing my own system). My needs in that department are planned to be very basic, so I've just slapped together a few checks for elemental damage types so I can give enemies weaknesses.

    In the video below is a test I threw together this afternoon showing different damage types. I achieved this with ContactDamage components set to do enough damage to the player that they essentially work the same way as an instant death because I haven't modified Rex's instant death mechanics, but the result is the same. Touching the poison pool kills the player and plays a little green skull particle effect, touching the enemy kills the player in the default way, and falling down the pit causes an almost kind of Smash style death with multiple particles playing together and a little slow-mo thrown in for effect. I could have added a zoom on the character as he dies but I use ProCamera2D to handle my cameras and I didn't want the example to require anything but Rex. For both the poison pool death and the pitfall death I just disabled the sprite renderer to make the player disappear but have their body still technically present.

    There's nothing advanced at all about this system, and it's quickly thrown together with incomplete parts, but I am curious @BeeZee whether there are plans to expand upon that poison check? I've got my own that's a little ugly but functional, but an official solution might be handy for others. Mine needs a bit of clean up but the gist of it is that the Rex Actor and Contact Damage scripts have been expanded upon to speak to each other about their elements and weakness through basic variables, and perform the damage calculation process/custom effects accordingly.

     
    Last edited: Jan 6, 2020
    PhantomFox128 likes this.
  32. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    I think I had originally planned for a damage over time system; it's still something I'd like to consider for a future update. That whole BattleEnums sections totally is a placeholder for elemental damage, so it's pretty cool that someone noticed that!
     
    PhantomFox128 and Bagnol like this.
  33. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    Hi there! I wanna say I do love Rex Engine. It’s a great starting point and has just an adorable charm to it. There are some things, however, that stand out to me, mostly code-wise. It feels like there’s untapped C# potential in some scripts. For example, the Base State class has the ID variable that must be set in derived classes. A simple way to do this as an alternative to the existing method is to make the id variable into a virtual property and override it in derived classes. Even better if Base State was made into an abstract class and id was an abstract property there by forcing derived classes to override it. That’s just one example. There are more but I don’t wanna leave too much longer of a post. I still think this is just a great piece of software and would gladly recommend it. I would like to provide more feedback if it’s deemed helpful to you. Keep up the great work!
     
    BeeZee likes this.
  34. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Heya, sure thing, this kind of feedback is incredibly useful! Can you shoot me a PM with it?
     
  35. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    For the time, I've decided to focus on an on-screen explosion like death, so I guess my question now is, how would I go about setting this up? I've tried testing with keeping my character's sprite still active, but it seems like no matter what I do, I still get a coroutine error.

    While I'm at it, I'm wondering if there's a way to add a particle effect to the camera for a specific level? For example, if I wanted rain, I'd put a rain effect over the camera instead having to scale an effect over the entire level. Would something like that be better to do?
     
  36. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 Is the coroutine error the same one that was being caused by the player being destroyed on death? If not are you able to post the error here? For the sprite though, depending on the particles, you probably have their Sorting Layer in front of the player, so depending on the particles they could cover the player's sprite, otherwise you could just modify/extend the existing death process to deactivate only the player's Sprite Renderer component so the character is still technically there, just invisible while the death particles are being played - which is what I did in the demo video.

    As for the rain, it's definitely doable. I can't really comment on which way is best, but if you want to have it on the camera you could add it to Rex's Camera prefab but uncheck the box a the top of the inspector to have it start deactivated, then either have a script on the level activate the rain on the camera, or have a script on the camera (or somewhere else) check if it's on a level that needs rain and activate it from there.

    If you do go that route, you'll probably want to set your rain's simulation space to "World". If it's set to "Local" the individual rain particles will move with the camera and not look right, but if set to "World" it will generate new rain particles as the camera moves. If you're unsure of what that means, if you've got a rain particle system, place it into the editor and have it play, then drag it left and right with the different simulation space settings and it'll make sense.
     
    PhantomFox128 likes this.
  37. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    Hi, I find a bug. When my hero has wall climb ability and I stand on OneWayPlatform and near the wall, I drop down from OneWayPlatform and it looks like this:
    GIF.gif
     
  38. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    So, it seems to be the same one, but some of the script lines it's referencing are slightly different. Either way, here's the error again:

    Coroutine 'PlayCoroutine' couldn't be started because the the game object 'StarBurst2D' is inactive!
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    RexParticle: Play() (at Assets/RexEngine/Scripts/RexEngine/_Components/RexParticle.cs:15)
    RexEngine.RexActor:SetDeathParameters() (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:896)
    RexEngine.RexActor: Damage(Int32, Boolean, DamageType, Collider2D) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:549)
    RexEngine.RexActor: ProcessCollision(Collider2D, CollisionType) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1126)
    RexEngine.RexActor: OnTriggerEnter2D(Collider2D) (at Assets/RexEngine/Scripts/RexEngine/_Abstracts/RexActor.cs:1176)

    I also tried with another particle effect and got the same thing, and I made sure the RexParticle script is attached.
     
  39. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @PhantomFox128 Does the particle prefab have a script on it that causes it to destroy itself by any chance?
     
  40. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @Codinggamer223 I might be misunderstanding but I don't think that's a bug - jumping while crouched is supposed to make your character fall through one way platforms.
     
  41. hippobob

    hippobob

    Joined:
    Feb 26, 2017
    Posts:
    33
    Hi, I have a problem. When the character I control suddenly changes direction of movement in quick succession, the character's attack direction does not change. As shown in the figure above, how to set it?
    I can only use combo to avoid this problem. But there will still be one or two attacks without a timely turn.
    In addition, only melee weapons are problematic. Long range weapons no problem.
     

    Attached Files:

  42. hippobob

    hippobob

    Joined:
    Feb 26, 2017
    Posts:
    33
    upload_2020-1-12_17-43-1.png 哈哈 我找到了!!!Select Turning and OK! !! !! Haha the Chinese are too difficult to read English!
     
    Bagnol likes this.
  43. Bagnol

    Bagnol

    Joined:
    Sep 5, 2013
    Posts:
    169
    @hippobob Glad you found it - I was just about to upload that same image as you made your post :)
     

    Attached Files:

    hippobob likes this.
  44. PhantomFox128

    PhantomFox128

    Joined:
    May 22, 2019
    Posts:
    157
    The JMO Particles have a script attached to them, but others don't. Tried them both and getting the same result.
     
  45. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    @Bagnol , I fix this bug. The WallClingState always could active when you against the wall. When I crouched and press down and jump button, the WallClingState check I'm in wallcling and could jump because I press the jump button in the same time. So it change to wall jump.

    I just simply diable the WallClingState in RexController when I drop down from OneWayPlaftrom.

    Original Code
    Code (CSharp):
    1. protected IEnumerator DisableOneWayPlatformsCoroutine() //Don't call this directly; this just helps DropThroughOneWayPlatform do its thing
    2.         {
    3.             if(slots.physicsObject)
    4.             {
    5.                 if(StateID() == StairClimbingState.idString)
    6.                 {
    7.                     StairClimbingState stairClimbingState = GetComponent<StairClimbingState>();
    8.                     if(stairClimbingState != null && stairClimbingState.canDropThrough)
    9.                     {
    10.                         stairClimbingState.Drop();
    11.                     }
    12.                 }
    13.  
    14.                 slots.physicsObject.DisableOneWayPlatforms();
    15.                 while(slots.actor.timeStop.isTimeStopped) yield return null;
    16.                 yield return new WaitForSeconds(0.25f);
    17.  
    18.                 slots.physicsObject.EnableOneWayPlatforms();
    19.                 yield return new WaitForSeconds(0.1f);
    20.             }
    21.         }

    My Code:
    Code (CSharp):
    1. protected IEnumerator DisableOneWayPlatformsCoroutine() //Don't call this directly; this just helps DropThroughOneWayPlatform do its thing
    2.         {
    3.             if(slots.physicsObject)
    4.             {
    5.                 if(StateID() == StairClimbingState.idString)
    6.                 {
    7.                     StairClimbingState stairClimbingState = GetComponent<StairClimbingState>();
    8.                     if(stairClimbingState != null && stairClimbingState.canDropThrough)
    9.                     {
    10.                         stairClimbingState.Drop();
    11.                     }
    12.                 }
    13.  
    14.                 if( wallClingState ) wallClingState.isEnabled = false;
    15.                 slots.physicsObject.DisableOneWayPlatforms();
    16.                 while(slots.actor.timeStop.isTimeStopped) yield return null;
    17.                 yield return new WaitForSeconds(0.25f);
    18.  
    19.                 slots.physicsObject.EnableOneWayPlatforms();
    20.                 yield return new WaitForSeconds(0.1f);
    21.                 if( wallClingState ) wallClingState.isEnabled = true;
    22.  
    23.             }
    24.         }
    Hope @BeeZee could fix the problem next time^_^
     
  46. skinny_

    skinny_

    Joined:
    Feb 3, 2018
    Posts:
    6
    Hi guys. Is there any opportunity to shoot projectiles in any direction, not only 8-way aiming?
     
  47. zengsadi233

    zengsadi233

    Joined:
    Aug 15, 2017
    Posts:
    13
    I found another small logic bug in RexController.cs, If I want to control player move through AI( or Script ), I use RexActor.RemoveControl method and then use RexController.SetAxis method but it didn't work.
    in RexController.Update method:
    Code (CSharp):
    1. void Update()
    2.         {
    3.             if(slots.input )
    4.             {
    5.                 axis = new Vector2(slots.input.horizontalAxis, slots.input.verticalAxis);
    6.                 CheckForOneWayPlatforms();
    7.             }
    8.         }
    I add another condition and it work:
    Code (CSharp):
    1. void Update()
    2.         {
    3.             if(slots.input && slots.input.isEnabled )
    4.             {
    5.                 axis = new Vector2(slots.input.horizontalAxis, slots.input.verticalAxis);
    6.                 CheckForOneWayPlatforms();
    7.             }
    8.         }
     
  48. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Yep, you can make that happen with a small bit of code. Projectiles have the following function:

    Code (CSharp):
    1. public void FireAtAngle(float angle, Vector2 _startingPosition, Direction.Horizontal _horizontal, RexActor _spawningActor, RexPool _parentSpawnPool = null)
    That will let it go in any angle you'd like. You can see an example of that getting called on line 469 of Attack.cs, where a projectile gets created and then fired at an angle.
     
  49. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for pointing that out! Another potential solution (and the one that I think enemies use) is to temporarily remove the reference to your slots.input. You could potentially buffer it in another variable on your player, so you'd have easy access to it when you wanted to restore it to slots.input.
     
    zengsadi233 likes this.
  50. BeeZee

    BeeZee

    Joined:
    Sep 25, 2012
    Posts:
    657
    Thanks for letting me know. Looks like the wall jump needs an additional check to make sure the player isn't grounded. I'll try to get that fixed up for the next update.

    EDIT: Fixed! It'll be part of the next update.
     
    Last edited: Jan 17, 2020