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. THEAK472009

    THEAK472009

    Joined:
    Jan 24, 2013
    Posts:
    21
    Here is a bug I found in the demo.
    Its pretty funny but also serious from a technical point of view.

    Video:
    https://drive.google.com/open?id=0Bxa7g0oZu4tESGR2YWVobGVLSzQ

    We are working on a 3D platformer and I played the 3D demo. Does the 3D part of the engine have the same features like 2D? If not what are the missing features. A reply will really help us to decide whether to write our own or use this nice engine.

    Thank you.
     
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @THEAK472009 > That's a known issue, and it's to be expected. The corgi engine is raycast based, if you want to interact with physics for more than just really basic stuff (pushing a block along a flat path for example), go for a physics based engine. An alternative physics controller is coming soon, but the (current) raycast one will probably never support complex physics interactions like that, that's not what it's built for.

    And the 3D part of the engine (well technically it's 2.5D, 3D assets but you only move on a plane, like in Limbo for example) is the same as the 2D part for most classes. There's a dedicated 2.5D camera controller, but apart from that everything else is common to both Ds, and you can also mix both if you want, have sprites walking in a 3D world for example :)
     
  3. THEAK472009

    THEAK472009

    Joined:
    Jan 24, 2013
    Posts:
    21
    Thanks for the replies. Yeah our game has only basic interactions like pushing a block.
    But since our game is a perspective puzzle, there is change of gravity involved. So you will always move in 2d plane but the plane can change from XY to XZ. Does the engine support that?
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @THEAK472009 > No, it does not. You could implement it of course, but it looks like you'd be better off with a 3D framework rather than a 2D one.
     
  5. Plott

    Plott

    Joined:
    May 12, 2014
    Posts:
    94
    Is there anyone out there who has written a successful override function? I'm having issues writing a simple override for the Kill() function and for the life of me can't figure out what I'm doing wrong. I'll admit, I'm not a great coder and this is my first time using overrides.

    I'm trying to override the Kill function in the health script to play a blood splatter and explode body parts of the character when they die.

    Heres my code.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.Tools;
    5.  
    6.  
    7. namespace MoreMountains.CorgiEngine
    8. {
    9.     public class HealthKill : Health
    10.     {
    11.        
    12.         public GameObject Blood;
    13.  
    14.         public Exploding _explode;
    15.  
    16.         protected override void Initialization()
    17.         {
    18.             base.Initialization ();
    19.  
    20.             _explode = GetComponent<Exploding>();
    21.         }
    22.  
    23.         public override void Kill()
    24.         {
    25.  
    26.             _explode.OnExplode();
    27.  
    28.             if (Blood != null)
    29.             {
    30.                 Instantiate(Blood, transform.position, transform.rotation);
    31.             }
    32.  
    33.             base.Kill ();
    34.         }
    35.  
    36.     }
    37. }
    I've looked everywhere and have no idea what I'm missing. Also does anyone know a good to test is an override function is working? I read the Debug.Log doesn't call on overrides, and I couldn't get it to work with Debug.Log either.

    Anyways, thanks
     
  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Plott > As I said in my emails, and so it can help anyone else who'd have the same question : yes, debug logs will be called, whether you're extending a class or not. I mean they work, like anywhere else. Why you don't see them is probably the reason why it's not working though. You need to track why. Could be a bad component setup, could be something else you changed, but using debug logs or the debugger should help you pinpoint the problem.
     
  7. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Plott > Oh and there are quite a few examples of overrides in the engine itself. The melee weapon, dynamic joystick or all ability classes are examples of extended classes. There are of course many more.
     
  8. Plott

    Plott

    Joined:
    May 12, 2014
    Posts:
    94
    @reuno Thanks! I'll look at the melee weapon and dynamic joystick! I figured I'd post this here incase someone had an answer and if someone else has the same issue. Thanks for all your help, not trying to annoy anyone here with my negligence in coding!
     
  9. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Plott > I'm sure you're not bothering anyone :) Try what I said, if you're still stuck, send me another email and I'll have another look.
     
  10. beach3d

    beach3d

    Joined:
    Mar 16, 2016
    Posts:
    9
    When I export my sprites out of Spine, they are fine except for crouch. When I have that assigned to the character it seems that instead of the head going down with the legs planted, the legs move up with the head so there is a gap from the feet to the ground when crouched. Any idea what could be wrong, I'm guessing something with my setup but everything seems fine at my end.
     
  11. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    Hi! @beach3d
    Did you check the box collider size when crounched?, maybe it's too big and because of that, it's causing that gap( in the crouch ability, there is a place that you can change the collider size when crouched)
    I imagine that this is the cause because I had a similar issue heheheh ^^
    I hope I could help in something, but for sure, @reuno will come and give you the right answer ^^
     
  12. beach3d

    beach3d

    Joined:
    Mar 16, 2016
    Posts:
    9
    Hi Zehru, thanks for the response. Unfortunately, it does not work even with the 'resizecollider when crouched' check box checked. I've also tried adding an individual collider to the crouch.anim instead of letting it inherit the collider from the idle.anim and same results. Any other ideas or something I might be missing? My crouch sprite is indeed smaller than any other. It just seems to be pulling the legs up to the head, instead of dropping the head down to the legs.
     
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @beach3d > I guess it's something you can set from Spine when you export. You could add an offset so all your animations "align" (meaning you'd have more empty space over the head of your crouched character).
    What I usually do when working with Spine to avoid this is have the center positioned between the feet of my character. That way all exports align on this point. In any case, it's more of a Spine issue than a Corgi Engine one :)
     
  14. beach3d

    beach3d

    Joined:
    Mar 16, 2016
    Posts:
    9
    I was just writing a response, and thats exactly it! I had taken the sprites into photoshop and given them an appropriate space above head and sure enough, they are level and working. Thank you for the more technical response, it will help with other assets! :)
     
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @beach3d > You're welcome, I'm glad it's working now :)
     
  16. heyteg

    heyteg

    Joined:
    Mar 2, 2015
    Posts:
    3
    Hey reuno!:)
    Just noticed that if i remove the GUImanager gameobject from any scene, and press play, i get this error about some healthbar. I'm guessing this isn't as intended as i think i read somewhere that the GUImanager wasn't required in the scene?
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @heyteg > You're right, it shouldn't happen. I'll fix that for the next release, thanks for reporting this!
     
  18. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Hi,
    I tried to compile the Corgi Engine to IOS and it was imposible using Unity 5.5.1. All the import settings sprites aren't configured to IOS, only to default (Standalone builds?). There are some quite big textures (there is one 4096x8192!) and a lot with 4096x4096. Once I reimported all those sprites at lower resolutions everything went fine and I can confirm that Corgi work pretty well in IOS (iPhone 4s) with a beautiful & smooth camera scroll at 60 fps.

    Reuno, could you please take a moment and configure all the project sprites import setting in next release ( IOS and Android at least). The project doesn't compile on IOS by default and I don't want to tweak all those sprites again if I update your asset to future versions.
    I haven't tested on Android but with that texture sizes I suppose there will be some runtime memory problem depending on the device.
     
    Last edited: Jan 28, 2017
    reuno likes this.
  19. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @jocyf > Of course including 4096x8192 in a mobile game isn't a good idea :) But the engine targets all platforms, not only mobile. Plus these textures you mention are placeholders, you're meant to replace them with your own.

    That said, I've been compiling for iOS and Android without any trouble (there's a demo for the engine on both stores), and quite a few people have released games on both platforms, and didn't get these errors, so I'm not sure how to reproduce this. I won't change the settings to lower resolutions though. I'd get the opposite complaint from people who target PC or PS4, and again, these are just placeholders.

    Edit : just to be clear : tell me exactly what error you got, and how, and I'll fix it :)
    Edit 2 : ok I didn't know about the separate sprite settings thing. Silly me. I'll have a look at it for the next release! What max size should I set?
     
    Last edited: Jan 28, 2017
  20. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    There is no error when compiling, Unity just continue compiling and never ends while Packaging resources.asset

    Once I reimported the sprites on IOS at lower resolutions (you can just tweak the PC/Android/IOS Import settings in each sprite in the project) I was able to compile the XCode project and everything is fine now (just lowering resolutions is enough to make it work).


    Max size: It's very mobile device dependent (how much RAM the device has). If the game try to get much memory in some low/middle device, the game could crash. XCode lets you know how much memory you are using in every single scene, so it's easy to know what is happening in the device at runtime.

    I usually use 1024x1024 atlases for anything in-game (character frame animations, props, etc) and 1024x1024 for backgrounds if needed. If something doesn't fit (o gets blurred) in a 1024x1024 image size you can use some 2048x2048.

    Of course, there are high specs tablets and phones with 1 GB ram where those requirements are not longer so limited. But I never use anything beyond 2048x2048 in mobile.

    I've compiled Corgi on my iPhone 4s (512 Mb) and mesa2 scene uses 100Mb (the background needs more resolution, is a little blurry at 1024) but you get an idea... every runs smooth at 60 fps.

    Transitions between scenes, going back to main menu from any play-scene, causes some strange things in screen (something is been drawing against the black background, maybe the UI??) while loading the new scene, but it seems to be a minor bug.
     
  21. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @jocyf > Regarding the endless compiling, you may have run into this known issue with the post processing effects :
    They tend to take extremely long on the very first build (you shouldn't have the problem if you build again). It seems to only affect some people (ran into it myself recently):

    You can learn more about that issue there :
    https://github.com/Unity-Technologies/PostProcessing/issues/28#issuecomment-270376962
    and there :
    https://github.com/Unity-Technologies/PostProcessing/issues/39

    The transition thing you're seeing is probably the loading scene manager. It does draw and write stuff in between scenes. Feel free to just call regular transitions :)

    That said, I'll have a look at these settings. Thanks for your feedback and the detailed info!
     
  22. DeeCode87

    DeeCode87

    Joined:
    Jan 29, 2017
    Posts:
    2
    Hi @reuno
    Thanks for this great asset. It is a great help for me to create platformer game.

    I have some question about this assets,
    I try to make some event (maybe a simple cutscene), where there is a conversation between the player and the NPC and make the player or the NPC move to somewhere in scene.

    What is the best practice for your framework? should I override some script that already provided by you? or should I create my own script for this?

    I'm very new in coding so I hope you can give some simple explanation for this :)

    Sorry if my question is repost

    Best Regards
     
  23. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @DeeCode87 > Good question :) Apart from the dialogue box there isn't much in the corgi engine to create cutscenes. The reason for that is that cutscenes are really specific to each game, and usually don't conform to a single universal pattern. If it's really a custscene, I'd say the best way is to either create your own classes that move the characters (without the constraints of the engine) or maybe use Unity's Mecanim to do so.
    Alternatively you could build scripts that move the actual controller/Character/etc the same way the AI scripts currently do, but that seems a bit overkill for simple cutscenes.
     
  24. ThoZ

    ThoZ

    Joined:
    Apr 21, 2013
    Posts:
    29
    reuno likes this.
  25. matteo-piccioni

    matteo-piccioni

    Joined:
    Jul 4, 2014
    Posts:
    49
    Maybe you could use the LevelSelection scene to achieve what you need ( LevelMapPathElement and LevelMapCharacter scripts) ?
     
    reuno likes this.
  26. DeeCode87

    DeeCode87

    Joined:
    Jan 29, 2017
    Posts:
    2
    @reuno thanks for your explanation. Yes it will be my homework then :). Yes your AI Script is really helping.

    @matteo-piccioni I haven't check and try LevelSelection and LevelMapPathElement, I think I will try to look at it. Thanks :)
     
    reuno likes this.
  27. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    It's being a while from the last time I had the chance to play with the engine. Love the new features, keep up the good work @reuno !!

    Have a doubt about weapons.
    Is there some way I can set the ammo available for each one? because I don't see it on the inspector. If not, can I suggest it?
     
  28. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Muppo > I'm glad you like the new features :)
    Ammo is not included yet, but it's already been requested (and was my part of my plan all along). It's coming to the next major update!
     
  29. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    I try to make an AI character with two parts: a body and a head both random from a collection, then spawn the entity as an enemy.
    Is there any way I can achieve this with the tools included on 3.1?
     
  30. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    How easy is it to integrate your achievement system with the Steam API?
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Muppo > Nothing specific no, I'd say Spine is the right tool for something like that (and there are Spine examples in the engine), but really it's a feature that is quite independent of the engine, so I don't have much to say about it :)
    @Cereal_Killa > "how easy" is always very hard to answer. There's nothing specific to the Steam API in the engine, but the current implementation is relatively similar to the Steam API. I'd say it'd be easy for me or any seasoned developer. Instead of speaking in easy/hard terms, know that the Engine allows you the means to trigger and load achievements, all there is left to do is add similar calls to any social API you want. The main difficulty might be the Steam API's documentation. Last I checked it wasn't the best out there, but it may have improved since :)
     
  32. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    I found an example of Achievements in the .NET Steam API Wrapper at: https://github.com/rlabrecque/Steam...r/Assets/Scripts/SteamStatsAndAchievements.cs

    Homepage: https://steamworks.github.io/

    Perhaps a developer more seasoned that I can integrate them somehow ;)

    The most I've integrated thus far is ProCamera2D which I just purchased today.
    For anyone else using ProCamera2D with Corgi this is what I did:

    Open ProCamera2D.cs and in the Start function before "// Center on target" add:
    // Add Camera Target
    AddCameraTarget(MoreMountains.CorgiEngine.LevelManager.Instance.Players[0].transform,1f,1f,0f);

    And be sure to add the ProCamera2D component to the main camera in each scene of course!
    Also to handle death correctly you'll need to comment out the references to the Corgi Camera in the LevelManager.cs script:

    //_cameraController.FollowsPlayer=false;
    yield return new WaitForSeconds(2f);
    //_cameraController.FollowsPlayer=true;

    Then it's up to you whether you freeze the camera in position and turn off player collision (default Corgi action) or whether you have some other death animation such as a ragdoll effect.

    Also, there's a number of other tweaks you can do to copy Corgi effects or customise cameras further, but those are the basics.
     
    Zehru and reuno like this.
  33. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Thanks but I'm not using Spine yet and DragonBones seems to work badly on Unity. I will try just to make them random spawned from several prefab models.
     
    reuno likes this.
  34. Tijs79

    Tijs79

    Joined:
    Feb 5, 2017
    Posts:
    16
    Hi Reuno,

    First of thanks again for this great asset.

    While learning the engine functions past week I noticed a small bug. Maybe it's already noticed here but I couldn't find it.

    It becomes visible if the Health script is active and "Flicker Sprite On Hit" is set. When an enemy has been shot and respawns when the player dies, the enemy sprite stays red when it respawns.

    Probably the Flicker state has to be initialized upon respawn again when the players dies in the Health script.

    It's reproducable in the Lava Demo level.
     
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Tijs79 > Thanks a lot for reporting this! I'll have a look at the problem and fix that for the next release.
    Drop me an email if you need a fix for that faster!
     
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Tijs79 > I've had a look at that bug you reported, and it's fixed.
    The fix will be included in the next release. If you need it before that, just let me know, I'll send you the updated file.
    Thanks again for reporting this!
     
    Tijs79 likes this.
  37. heroes1

    heroes1

    Joined:
    Nov 16, 2015
    Posts:
    17
    Hi Reuno,
    I like this corgi Engine 2D. Have you ever thought of implement UNET into this package?
    It will be good to have multiplayer mode.

    Thanks
     
  38. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @heroes1 > I have thought of implementing it, yes. I've actually spent 6 months on that. I gave up for a few reasons : UNET is still pretty buggy, at least in my experience, and most importantly the way you setup your network game is really dependent on the kind of game you want to make, and your exact gameplay. Meaning that you'll have different settings, and save/sync things differently if you're going for a fast paced action game or a coop one, etc. Given the many possibilities currently offered by the Corgi Engine it was just too hard to offer an online solution that would fit everyone.

    What I ended up doing was reusing that code for my latest asset, Highroad Engine (https://www.assetstore.unity3d.com/en/#!/content/73798), which is much simpler in terms of gameplay, and where perfect sync is less important, and UNET works very well for use cases like this.

    That said, it's very doable to take the latest version of the Corgi Engine and turn it into a particular multiplayer game. It's just the "one solution for every game style" that is (in my opinion) not possible right now.
     
  39. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    How about a multiplayer platform game where each person controls a different character?
    Similar to minecraft, terraria, salt and sanctuary, etc?
    The only things to decide are shared items or individual items, shared xp or individual xp, shared progression to next level (requiring either one or all to finish - or one plus a countdown timer similar to a racing game), or each player has their own progression and can be on different levels, do you wait for all players to load a level before starting or each player can start when they're ready? PvP on or off or turned on/off unless in trigger zone or player entering a command or pressing a button, etc.
    You could implement checkboxes for these so Corgi users could have it one way or the other.

    Any level updates such as player movement, actions, mob kills, blocks destroyed, etc would be sent to the other plaeyrs and synced.

    One player would act as a server and the others would connect (peer to peer is too laggy with many players), so any actions the host takes would take precedence in terms of syncing data so the host should probably play healer ;)

    The Corgi engine is quite simplistic itself being a level based system without streaming. It should be quite easy for someone as knowledgeable as yourself to add basic multiplayer to this to allow those of us less fortunate to create basic multi games.
     
  40. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Cereal_Killa > No, I'm afraid it wouldn't be "quite easy" to do that. Of course, creating the very specific game you describe is doable, but people are using the engine not just for terraria clones, but also for PvP shooting games, coop platformers, etc. And while these will share some common features, when it comes to multiplayer this is a whole other level, and what and how you'll build the network part will differ greatly. And sadly it can't just be resolved with checkboxes here and there, it's just not that simple. Especially not with UNET.
     
  41. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Ok it just seems like the rules that I laid out allow for both PvP shooting and co-op platforming, and Terraria actually includes both of these things so while people won't be directly cloning Terraria (I hope) their games may include some of these aspects that we both mentioned.

    Even having the above as a starting point would help greatly. Even with the single player corgi engine you like to keep it as bare bones as possible and are always declining specific niche requests like grappling hooks; it would be no different for the multiplayer side.

    Maybe I'm missing something or it's too hard (if it was easy then someone would have done it already, right?), but if you can make a multiplayer racing game then I wouldn't think a multiplayer platformer would be much of a stretch (unless we're recreating Robocod ;) ).
     
  42. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Cereal_Killa > I was on the same line as you until I started digging into actual network code a few years ago.
    Sure, I could add one single example, but speaking from experience here, it'd only please a very small part of the users, and I wouldn't be able to guarantee the quality. Doing that on Highroad took me almost a year, and again it's only one use case, and one extremely simple when compared to the possibilities offered by the Corgi Engine.

    The Corgi Engine is "online ready" in that it won't get in your way if you decide to add a network layer. But providing that as an asset wouldn't meet my (self defined) quality standards, and I won't do that in the current state of UNET.
     
    Zehru likes this.
  43. Tijs79

    Tijs79

    Joined:
    Feb 5, 2017
    Posts:
    16
    @reuno > Thanks, not in a hurry, working on artwork still.

    Just for my understanding was the problem in this part of the Health script code:

    protectedvirtualvoidOnEnable()
    {
    CurrentHealth=InitialHealth;
    DamageEnabled();
    UpdateHealthBar();
    }
    or in the MMImage class?

    On other small suggestion:

    The $ sign is hardcoded in the GUImanager class, since I use a non-monetary score I had to remove this in the standard class code. Changing the Text script text of the LevelText object doesn't seem to overule this GUImanager class code. As this code change affect a standard class, it will be overuled by future updates I assume.
    Maybe this Text addition can be made variable on the GUIManager script or left out fully as the sign can be added manually in the Canvas layer anyways (I use a sprite now added to that layer).
     
    Last edited: Feb 8, 2017
  44. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Tijs79 > It was a problem in the Health script (more or less where you point, but at some other places too). The MMImage class was fine.

    And you're absolutely right regarding the $ sign, I'll change it so it's not hardcoded anymore. Thanks for spotting this!
     
  45. Tijs79

    Tijs79

    Joined:
    Feb 5, 2017
    Posts:
    16
    EDIT: I found the reason: OnTriggerEnter does only work for 3D. I changed it inOnTriggerEnter2D and OnTriggerExit2D and now the script does what I want. This is so cool I begin to like this C# :)

    The engine contains almost everything I need for my game idea but lacks one function to provide for a puzzle component.
    I want to implement a function that can switch a gameobject 'on' and 'off'. Note that this is my first c# coding experience so excuse me if I do things whoch are not very logical.

    I succeeded in the on part already using the override function in the ButtonActived script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5.  
    6. // Button action override to toggle a gameobject on
    7.  
    8. public class MoveStone : MoreMountains.CorgiEngine.ButtonActivated {
    9.     public GameObject GameObject;
    10.  
    11.     public override void TriggerButtonAction ()
    12.     {
    13.         base.TriggerButtonAction ();
    14.         GameObject.SetActive (true);
    15.     }
    16. }

    So I tried another thing with some standard Voids for OnTriggerEnter and OnTriggerExit, to see if I was able to set the gameobject on and of by detection of the character for a collider object with the following script attached. The script does not gives errors but it doesn't do anything as well :).

    [EDIT] Below is now the working code. Add this script to a game object with Box Collider 2D setup. Drag the game object which you want to toggle on and off into the GameObject field of the script in the inspector. Tommorow I'll try to make the scripts of the target game objects also variable so you can choose to only toggling a specific script.
    One thing to note; the code as is below will only toggle on or off if your character is present in the area. If you want also other objects to interact like pushable boxes etc. you could replace "CorgiController" into "BoxCollider2D" for all occurences.
    Downside of this is that the area will be triggered for all for objects having the BoxCollider2D set (so also potential enemies) so you have to take that into account when designing your level.
    Reuno probaly can program a more foolproof solution but for my game this is all I need. Happy puzzle platforming!:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. namespace MoreMountains.CorgiEngine
    4. {
    5.     /// Use a collider2d trigger to activate gameobject on "OnTriggerEnter" and
    6.     /// deactivate the gameobject on "OnTriggerExit"
    7.     public class StepCollider : MonoBehaviour
    8.     {
    9.         public GameObject GameObject;
    10.  
    11.         void OnTriggerEnter2D(Collider2D collider)
    12.         {
    13.             CorgiController controller=collider.GetComponent<CorgiController>();
    14.             if (controller == null)
    15.             return;
    16.             GameObject.SetActive(true);
    17.         }
    18.  
    19.         void OnTriggerExit2D(Collider2D collider)
    20.         {
    21.             CorgiController controller=collider.GetComponent<CorgiController>();
    22.             if (controller == null)
    23.                 return;
    24.             GameObject.SetActive(false);
    25.         }
    26.  
    27.         }
    28. }

    If I can get the last part working, it'll give cool functionality for puzzle things, like opening doors or moving platforms on demand, but also like pushing a block on the collider to keep doors open etc.

    Maybe the functionality I need is already present, but I couldn't find examples of it or functions in the documentation.
     
    Last edited: Feb 9, 2017
    Muppo likes this.
  46. SunnyLax

    SunnyLax

    Joined:
    Feb 9, 2017
    Posts:
    5
    Hi,
    Is there a way available to make the player stick to the ground? When going on a slope at certain speed the player will come loose from the ground. Setting the y gravity of a ground object higher does not to work.

    Anyone have an idea how to solve this problem?
     
  47. Tijs79

    Tijs79

    Joined:
    Feb 5, 2017
    Posts:
    16
    Did you set the Box Collider 2D correctly on your character by using the "Edit Collider" button?
     
  48. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    I was trying to make a script which lets me spawn random prefabs from an array but my C# skills are near zero. Fortunatelly a friend of mine who work writing code gave me a hand.

    As @Tijs79 just did, I think sharing it is the right thing and maybe it can be useful for someone.

    Just need a empty game object with this script attached to work. It spawn any amount of prefab from the list of n elements at the set rate. You can configure it all on the inspector.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MoreMountains.Tools;
    4.  
    5. namespace MoreMountains.CorgiEngine
    6. {  
    7.     public class RandomSpawner : MonoBehaviour
    8.     {
    9.         /// Add this component to an object and it will spawn a random prefab from the list at the set rate until total amount is reached.
    10.         public int Amount;
    11.         public float Rate;
    12.         protected float timer;
    13.         public GameObject[] PrefabList;
    14.  
    15.         protected virtual void Start ()
    16.         {
    17.             timer = 0.0f;
    18.         }
    19.  
    20.         protected virtual void Update ()
    21.         {
    22.             if (Amount > 0)
    23.             {
    24.                 timer += Time.deltaTime;
    25.  
    26.                 if ( timer >= Rate)
    27.                 {
    28.                     Instantiate (PrefabList[Random.Range(0,PrefabList.Length)], transform.position, transform.rotation);
    29.                     timer = 0.0f;
    30.                     Amount--;
    31.                 }
    32.             }
    33.         }
    34.     }
    35. }
     
    Tijs79 likes this.
  49. beach3d

    beach3d

    Joined:
    Mar 16, 2016
    Posts:
    9
    I've been trying for quite sometime with no luck...Has anyone been able to implement a weapon animation through the character controller? So the default corgi has a gun out, so the weapon just fires from that sprite. But lets say I want my base character to pull out a weapon and fire? Where on the animator would I put those sprites of the weapon getting pulled out and firing? I'm guessing maybe something with the weapon attachment slot, but can't follow what needs to be done there.
     
  50. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,925
    @Tijs79 > I'm glad you got it working :) A proper key/chest mechanism is coming. It's been on my todo list for a while :)
    @SunnyLax > You can play with gravity to increase that, or change the raycast length on the CorgiController.
    @Muppo > Yeah, please don't hesitate to share, I'm sure it'll be useful to others :)
    @beach3d > Have you checked the documentation about that? It contains a detailed example of how to do that for a melee weapon (which is basically the same thing). Plus there are examples of that in the engine. http://reunono.github.io/CorgiEngine/weapons.html You can setup quite a few animations per weapon (starting, being used, ending, etc).
     
    beach3d and Muppo like this.