Search Unity

[RELEASED] Corgi Engine - Complete 2D/2.5D Platformer [new v8.0 : advanced damage system]

Discussion in 'Assets and Asset Store' started by reuno, Dec 18, 2014.

  1. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Hey @Luremaster,
    What I've done for a minimap is I have a separate camera for rendering the minimap (it's a child of the main camera and has the same bounds and position so that it moves with the main camera perfectly) which is rendered into a UI texture (so I can place/shape it however and wherever I want on the screen). Then each object in the game has a separate minimap icon sprite on it which is displayed only on the minimap camera using a culling mask on the minimap camera.

    I got the idea from an excellent Gamasutra article here: https://www.gamasutra.com/blogs/Pio.../Implementing_a_minimap_in_Unity_tutorial.php

    Hope this helps.
     
    reuno likes this.
  2. Luremaster

    Luremaster

    Joined:
    Dec 17, 2016
    Posts:
    9
    Thx for the insight. I was thinking in something like a x y coordinate in a image. The player can acess the map with a button. The map itself is a whole image with a mask and when the player enters a room or area the room on map is revealed by removing the mask on that room. Im still thinking on what i will do since my programming skill is limited.
     
  3. Askins

    Askins

    Joined:
    Jul 3, 2017
    Posts:
    15
    Hi everyone,

    I downloaded Corgi Engine yesterday and have been impressed by how extensive it is, it's a really great package. I'm not an experienced programmer however and I was wondering if anyone could help me out with a solution to the game I'm wanting to make. Essentially I'm after a Super Mario Run-like game where the character auto runs and wall jumps essentially change the direction of movement. I've made it work with prime31's 2D controller but found that I can't use that particular script in a commercial game so I've decided to try and make it work with Corgi Engine instead. It should be a straightforward job but I'm fairly new when it comes to coding and don't want to break the engine making it work in an inefficient way.

    My question is, what would be the best way of going about changing the engine for this purpose? At present I've made customised Horizontal Movement and Jump scripts so that it doesn't mess with the original scripts, and have added the following code to the JumpStart funtion
    Code (CSharp):
    1.         public virtual void JumpStart()
    2.         {          
    3.             if (!EvaluateJumpConditions())
    4.             {
    5.                 return;
    6.             }
    7.             // we reset our walking speed
    8.             if ((_movement.CurrentState == CharacterStates.MovementStates.Crawling)
    9.                 || (_movement.CurrentState == CharacterStates.MovementStates.Crouching))
    10.             {
    11.                 _characterHorizontalMovement.ResetHorizontalSpeed();
    12.             }
    13.            
    14.             if ((_controller.State.IsCollidingRight && !_controller.State.IsGrounded) || (_controller.State.IsCollidingLeft && !_controller.State.IsGrounded))
    15.             {
    16.                 if (_controller.State.IsCollidingRight)
    17.                 {
    18.                     _characterHorizontalMovement.SetHorizontalMove (-1);
    19.                 }
    20.                 else
    21.                 {
    22.                     _characterHorizontalMovement.SetHorizontalMove(1);
    23.                 }
    24.             }
    25.  
    26.             // if we're still here, the jump will happen
    27.             // we set our current state to Jumping
    28.             _movement.ChangeState(CharacterStates.MovementStates.Jumping);
    Apologies for the terrible coding, I'm still very much new to scripting. I then added a float called _motionDirection into the HorizontalMovement script so that I could set the direction, but I soon stopped as I thought it would mess with the rest of the scripts that handle player direction. It's somewhat working but there are a few problems:

    a. When changing direction on a walljump, it seems there is a lerp in place that eases when a player changes direction, is there any way to disable this without breaking the rest of the systems?

    b. If the character slides down a wall suspended in the air, once he leaves the wall (and is in a falling state) he continues travelling in the direction he was before. Is there a way to have the character not move in any direction when falling after a wallcling until its grounded again?

    c. Ideally it'd be great to have a corner grab, is this possible with the engine?

    Any help or example code would be greatly appreciated, and apologies for asking such basic questions I'm still learning a lot when it comes to C# and I'm still at the amateur end of coding!

    Thanks in advance,
    Phil
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @Askins > Best way to make an autorun game would be to extend CharacterHorizontalMovement so it doesn't wait for input but rather auto runs. And there you could add some behaviors to change direction when hitting a wall for example.
    a > extending to override the lerp (extending won't break anything if you're worried about that)
    b > again, extend to implement that specific behaviour
    c > it's possible, not built-in
     
    NAiLz likes this.
  5. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    @Luremaster Without coding knowledge, the method I mentioned would be a good method for you. That article I posted does a good job of explaining it and then you could just make a simple script for your game manager or character player which would have a public game object which you could drag in that minimap texture and on a button press it just toggles GameObject.SetActive(True/False) to turn it on and off with a button press.
     
    Last edited: Oct 20, 2017
    reuno likes this.
  6. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Looking at how key operated doors works I started to mess with both key operated and dialogue scripts and after a lot on essay and error this is what I achieve:


    Right now I'm tuning it but I think it can be nice for creating mini quests.
    No problem to share when done.
     
  7. Lairizzle

    Lairizzle

    Joined:
    Dec 6, 2014
    Posts:
    16
    @Muppo that is awesome! Very cool
     
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @Muppo > That is very cool indeed, thanks for sharing this!
     
  9. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    @Muppo > that is really great! Please share it when you can. Corgi community is the best :)
     
  10. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Thanks guys :)

    Making the final revision, mostly help text for inspector on how it works.
     
  11. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    If you could include a demo level like the one in the video that would be great :) #hyped
     
  12. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Ok, script checked and available.
    Edit: it's on the reuno repository now. Here.

    @skayster
    No demo needed at all, just replace Dialogue Zone script with mine and check the options you want, is all documented both on inspector and script :)
     
    Last edited: Oct 21, 2017
  13. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Hello I am new here..

    I want my (3d) character (right) hand to move with weapon while aiming. Its only rotating weapon by default.
    Any help? :)
     
  14. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @hermolenda > Hey, I think you're talking about IK? In this case, I'd suggest looking at how the Soldier demo characters are setup, I think that's what you're after.
     
  15. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Oh yes sorry I didnt see that one.
     
  16. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    @Muppo > Thank you so much! Been playing around with the script and it works great. Just wondering if there is a way to stop the player from accidentally using the item that is requested by the NPC? No worries if it's too complicated, the script is great already! :)

    @reuno > found a strange problem (hopefully it's not me messing up the scripts). If the "resize collider when crouched" is ticked in the CharacterCrouch script and set to less than normal size/speed, then for me the bug appears when I do the following:
    - press down to climb from the TOP of the ladder, but jump off before you reach the ground. The player then stays in the crouched size/speed once you're off the ladder and doesn't reset till you press crouch again.
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @skayster > It's not you, it's me :)
    Fortunately, it's already been reported and fixed. I'll include that fix in the next release.
    Drop me an email if you need the fix and can't wait until then.
     
  18. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @skayster , glad you like it.
    Found the same issue and I think making a dedicated Item script could fix it. Have not mesed much with inventory item creation yet to be honest. I'll found a way soon or later.
     
  19. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    @Muppo or perhaps something that moves it to an "invisible" inventory, such as weapons but hidden. Not sure if that's easier or harder #newbie

    @reuno Oh no worries, this is super minor, I will wait till the next release. Any idea what is coming in the next version? :)
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    Zehru, twomack37, Bagnol and 3 others like this.
  21. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Smells like tileset engine :)


    @skayster I'll take that on consideration, thanks

    EDIT:
    After a few try and fail, hidden inventory results to be the easiest workaround for me as suggested by @skayster.

    It required a slightly different version of the script and some tweaks on objects at the inspector, but it works nice.



    Here is the revised script and the instructions on how I configured this demo.

    Sorry for the poor quality of the video, my laptop can't make it fluent otherwhise.
     
    Last edited: Oct 26, 2017
  22. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    @Muppo I might be doing something wrong, but I can still select items from the special inventory with a mouse and then use them. Did I miss a step? Thanks!
     
  23. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    Wow, that so nice to see. The community growing and helping each other :)
    my computer is still broken( I need to buy a processor). After doing it, I'll also post some extension and create some others to help you guys. Most of mine are metroidvania stuff, so I hope it can be useful to some of you :)
     
    wekster, reuno and Bhanshee00 like this.
  24. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    No, you're not, that's why I called it workaround instead solution. This does not protect item from use but, as it is not on the main menu, using it by mistake is not as easy as before.

    The real solution will be if there's a new type of item kind of "special" or "protected" which player can't really use in anyway (i.e. dedicated keys) but this is something I can't reach with my current coding knowledge.

    Perhaps @reuno could take it as a suggestion, I don't know.

    @Zehru
    That sounds nice, hope you can afford that new CPU, can't imagine being without a working computer.
     
    Last edited: Oct 27, 2017
    Zehru likes this.
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @Muppo > I'm not sure I understand exactly what the problem is, but if it's just a matter of not interacting with an inventory, you can make it unclickable via the CanvasGroup component for example.
     
  26. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    What happens is that I try to make an item usable by a door but not by the player, something like "story item" on some games, these you can't use until a exact place/moment in the game.
    The way it works now, if you have a key marked as usable, both door and player can use it.

    If there's a way you can make it now, I definitely missed it.
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @Muppo > Why not create a different type of key then? That'd be the easiest way to do it. Like you have "regular keys" and a "magic key" that is only used by your quest.
     
  28. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    That's what I did with the Teddy Bear. The point is how to make it non usable by player but usable by the script on the door.
    Have to give it another try.
     
  29. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    So making it unclickale via canvas group and disabling arrow/keyboard movement actually worked. I have my lovely quest inventory filled with quest items, that cannot be used by the player! As I can't click on it, I can't see the "item details" canvas for it unfortunately, but it works. Quest time! :) Thank you @reuno @Muppo
     
    Muppo and reuno like this.
  30. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Hey there, have you considered using Physics2D.BoxCast for physics accuracy? I don't know the performance implications. But sometimes you might have for example a triangular structure. The peak of the triangle is too small and fits between the rays, and it causes a bit of strange behavior.

    To add, I just bought this today to try it out and so I don't know much about what has been discussed already (boy, that's a lot of pages of posts to go through!)
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @JasonBricco > The whole point of the engine is to not use physics :)
    And yes, if you're going for spiky ground with tiny little bits, you should go for a physics engine instead. Using the Corgi Engine that's something you'd eliminate at the level design phase (like in most actual games in fact).
     
    Last edited: Oct 28, 2017
  32. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I figured that the engine was using raycasting from the physics API. And I figured that box casting is just an alternative to raycasting to get a 'thick raycast' that's more accurate (and perhaps better performing).

    If you made your own custom raycasts that work on Unity's colliders, then I would rephrase my question to: have you considered using a custom box cast that works on Unity's colliders?

    In either case, spiky things seem like something that would be common in a platformer. And having to use a nasty physics engine and ruin the feel of everything else just to support spikes is very lousy.

    Oh well, thanks for your response. I'll figure something out.
     
  33. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @JasonBricco > Look at classic platformers, not physics based, and see if you find spiky bits that are smaller than the character's colliders. It's actually not common at all.
    But sure, you can implement boxcasts instead, it's certainly doable by extending the CorgiController class. More expensive of course, but if that's what you need then go ahead :)
     
  34. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I suppose you're right, I quickly thought of ways to get around this problem that aren't too problematic.

    Although I do find it interesting that a box cast would be more expensive than 8 separate rays. I actually had no idea that was the case.
     
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @JasonBricco > I think it'd be more expensive if you want to reach the same level of control. With the current system you can tweak how many rays you want based on your specific needs. And knowing what each ray touches is useful too. But again, feel free to improve on it if you want to, or if you think box cast is better for you :)
     
    JasonBricco likes this.
  36. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    After more testing, this is really awesome. But it doesn't work in a very stable manner with the composite collider on the new tilemap system released in 2017.2. It seems quite easy to break past the collider and get trapped inside (with ray count = 8 on both axes, 45 degree angle slope, and running straight at it with run speed = 10). I wonder what can be done...
     
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @JasonBricco > I'm currently working on the next update, that will introduce a new demo based on 2017.2's tilemaps. So far I haven't met any problem with it, but I haven't played much with slopes as the colliders this system generates - even for simple slopes - seems just bugged right now, and it doesn't provide any form of control over it, as far as I know. Only solution I've found is to make the slopes prefabs, and use a custom brush to paint them, but it's really not user friendly. I'll wait until it gets better to add some. Overall I've found this system to be lacking in a lot of places, especially on the API side. So it'll just be a simple thing for now.
     
  38. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    My colliders in this random test level are generated like this:

    Composite.png

    And at that circled part is where (my friend who was testing) was able to break through. The slopes have worked quite well outside of this occasional thing.

    I personally haven't been able to break it, but I watched my friend break it fairly easily. How strange!
     
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    These colliders look good to me. I'll look into it if I ever manage to generate nice slopes with this thing. You might also want to increase your raycast length and count. 45° is the worst case scenario for raycasts.
     
  40. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Are there tricks to prevent going inside of one-way jump tiles (the ones where you can jump through from below but collide above)? Jumping at them from the side easily allows me to go inside and stand on the base of the collider.

    As for the other issue, I'm going to wait on that to see how things go. Making the rays larger didn't do a lot to help...
     
  41. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
  42. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Seems, unless I overlooked something, that I can't use edge colliders in the 2017.2 tilemap system and I can't edit the physics shapes to use only 2 nodes and be a line. When I edited it so that there was a very tiny gap between the two sides it seems to work. If anyone knows of a better way about this, I'd love to hear it!
     
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @JasonBricco > Yup, that's what I meant when I said the tilemap system currently provided very little control over colliders. It's all fine for simple objects/platforms that only require one, but as soon as you want to get a little more in depth, you're stuck. The only way I've found so far is to either use prefabs (and place tiles manually basically, thankfully they stick to the grid too), or create a custom brush for each kind of platform, that will basically place the colliders on Start (or however you prefer). A lot of work to add two colliders, I agree. I guess the tilemap forum / threads would have more info about that, I'm no expert on that myself.
     
    JasonBricco likes this.
  44. CaptCollins

    CaptCollins

    Joined:
    Jan 27, 2016
    Posts:
    13
    Anyone have any idea how to get scene transitions similar to a metroidvania or any 2d open world game you can backtrack in? Is there an easy way specify spawn location for the finish level script? Or to use checkpoints to remember where you left off? Or should I try coding it? Thanks a bunch!
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @CaptCollins > That's not something that is built-in right now (but coming soon, as it's been heavily requested). Right now the easiest way to do it is to add a new manager that keeps track of where you're coming from / where you're going, and gives that info to the LevelManager (by changing its starting checkpoint on Awake/Start.
     
  46. CaptCollins

    CaptCollins

    Joined:
    Jan 27, 2016
    Posts:
    13
    Thats awesome! Thanks.
     
    reuno likes this.
  47. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    The level thing mentioned by @CaptCollins is on my Wish List as well :)
    Also keeping fingers crossed for a feature for AI/player movement freeze on weapon attack start (thinking of heavy weapons like sledgehammers that sacrifice movement for a few seconds for high damage) for the coming updates.

    Btw, I've been playing around with the Corgi engine almost daily, can't get enough of it!
     
    reuno likes this.
  48. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @skayster > Weapon attack freeze is coming very soon too.
     
    Muppo, skayster and twomack37 like this.
  49. Sanhueza

    Sanhueza

    Joined:
    Nov 20, 2016
    Posts:
    28
    This might sound like a silly question (seeing as how this is a 2d/2.5d engine), but is it possible to make 3D games with Corgi? By this, I mean movement in 3D, such as in old school beat’em ups where you could move left/right, up/down (depth), and jump?
     
  50. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,929
    @Sanhueza > I won't say it's a silly question, but well it's a 2D engine :) Technically you could modify it, it's possible.
    But I'd recommend picking a 3D engine to do a 3D game, just a matter of picking the right tool for the job. There just isn't much in common in terms of core mechanics when you compare a top down game and a platformer (source : I'm working on both).
     
    Sanhueza and gameogami like this.