Search Unity

[RELEASED] Corgi Engine - Complete 2D/2.5D Platformer [new v6.0 : game feel, Cinemachine, and more]

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

  1. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    @reuno no problem, go ahead
     
    reuno likes this.
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
  3. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    Every time the player dies, Score is reset to 0. I want it to be persistent even from level to level because I want this to unlock levels, something like "you need 1000 score to get to the next level".

    I've looking at the managers already in the engine but I think I don't know where to start to dig. Anyone had done this or can give a tip?
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @Muppo > Points are reset in the SoloModeRestart method of the LevelManager :

    // we send a new points event for the GameManager to catch (and other classes that may listen to it too)
    CorgiEnginePointsEvent.Trigger(PointsMethods.Set, 0);

    (towards the end of it)
     
    Muppo likes this.
  5. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    Thank you!
     
  6. AxelBoltok

    AxelBoltok

    Joined:
    Jun 26, 2017
    Posts:
    10
    Hello, i think that there is a bug with the MeleeWeapon script, the damage area is not shown at all (the docs shows a gizmos), is there any way to fix this or is that im doing something wrong?, thanks.
     
  7. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    Hi reuno,

    I was wondering what is the best option to do the following:
    In one of the levels of the game I need to player to ride a car (of-course I will switch the player sprite with the car sprite), but what I was wondering about is how to setup my car object to make it move constantly? where the car will be moving the player will only when to jump from the different obstacles?

    Thanks in advance.
     
  8. CrazyEvilHamster

    CrazyEvilHamster

    Joined:
    Oct 13, 2018
    Posts:
    1
    Hello,

    First of all want to say big thanks for such nice tool like Corgi engine. Really good stuff. Saved a lot of time for me.
    But I have one issue with falling platforms. Maybe this issue already known and someone just could help me out with solution.

    Here is my problem: sometimes falling platforms just doesn't fall down. Here is one simple example. There are two yellow falling platforms. Y scale for smaller one is 0.2 and for bigger is 1. When I'm trying to jump on bigger platform everything is fine (not always, but usually). It shakes and falls. The main problem with smaller platform. Sometimes it falls down after few jumps, sometimes after 20 or more jumps.



    I looked into FallingPlatform.cs code and found the reason:sometimes variable controller.ColliderBottomPosition.y is a little bit less then variable _platformTopY

    controller.ColliderBottomPosition.y = -0.6324614
    _platformTopY = -0.6324613

    and this check just doesn't work (OnTriggerStay2D)
    Code (CSharp):
    1. public virtual void OnTriggerStay2D(Collider2D collider)
    2. {
    3.     ...
    4.             if (controller.ColliderBottomPosition.y >= _platformTopY)
    5.             {
    6.                 _timer -= Time.deltaTime;
    7.                 _shaking = true;
    8.             }
    9.     ...
    10. }
    in this case platform doesn't shake, variable _time doesn't decrease and platform doesn't fall down.

    It's just my thoughts, but maybe we shouldn't compare two floating point numbers just like that? Shouldn't we round (with some precision) these two numbers before compare them? Or maybe we should find difference between these two variables and compare it with some small epsilon?

    Thank you.
     
  9. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @AxelBoltok > You need to select the weapon for it to show. And sometimes it disables itself from the gizmos, seems to be a Unity bug (haven't been able to pinpoint it).
    @bravery > It really depends on what exactly you'd want, but a moving platform could do the trick.
    @CrazyEvilHamster > Interesting, thanks for reporting this. I'll look into a way to make this more reliable.
     
  10. NEHWind2

    NEHWind2

    Joined:
    Jan 7, 2016
    Posts:
    23
    @bravery

    I have a level like that in my current project. What I'm doing to get this effect is disabling the ability to move the player character altogether. Then I grabbed the entire level layout, put it into one parent gameobject, attached a Moving Platform script to it and setting it up so the entire stage scrolls towards the player giving the illusion of constant movement on the players part! It may not work for you depending on what you're building but that's a solution that worked for me so I thought I'd share!
     
    reuno likes this.
  11. hicksor

    hicksor

    Joined:
    Oct 18, 2018
    Posts:
    2
    I can confirm the problem with AI Brain and AutoRespawn. It happens with my own scenes as well as the RetroAI-scene. I added the AutoRespawn script e.g. to the little angry bird and when i die after killing it and it respawns at player respawn the AI does not work any longer. The angry bird just keeps walking into one direction forever.

    Also i have a problem with my own character after respawn. Parts of the character are simply not drawn any longer after dying for the first time. Though it only happens to parts of the character, e.g. the face while the rest of the character still appears as expected (the character is created with Spriter Pro, thus it consists of single sprites that are keyframe animated and controlled through mecanim).
    The strange thing here is: When starting the scene and the character is initially spawned everything works perfectly. Only after first death and respawn the problems appear. So the question most likely is: Where is the difference between first spawn at level start and respawn after death?

    EDIT: Also i found that when using the new AI Brain and Ai Actions (i copied the variant from the demo where the enemy is on patrol, attacks when in range and after that returns to patrol) after the enemy was killed and respawned he is facing the wrong direction (meaning he's walking backwards) depending on which direction he was heading while being killed.

    So if i kill him while hes walking right the character is facing correctly after respawn but when killing him while he's walking left he is facing the wrong direction after respawn. When i use the old and simple "AI Walk" script (without a brain) it doesn't matter which direction the enemy is facing when being killed, he is always facing correctly after respawn.

    Again: The AI brain and it's actions are working perfectly when starting the level. The problem appears only after a first kill and respawn of the enemy.
     
    Last edited: Oct 18, 2018
  12. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @hicksor > I really wouldn't know why parts of your character are not reactivated. There's nothing in the engine that knows about these parts, in fact the engine doesn't know about your model, or whether it's 2D spritesheets, a 3D model, a Spine thing, etc. So you must have something else happening.
    As for bugs, if you think you've found some, please use the support email and give me steps to reproduce in any of the demo scenes from a fresh install, right now it's just too vague for me to help.
     
  13. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    155
    @hicksor I don't have the editor running right now, but you should uncheck something like "destroy on death" or something like that in the character, that made the game behave like it should.
     
    reuno likes this.
  14. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    Thank you NEHWind2 for sharing you experience really appreciated.

    Is it possible to point me out to the "Moving Platform script" you are referring too? so I can give it a test.

    Thanks in advance.
     
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @bravery > I think the moving platform script @NEHWind2 is referring to is MovingPlatform.
     
    NEHWind2 likes this.
  16. Fabioisriva

    Fabioisriva

    Joined:
    Feb 3, 2016
    Posts:
    15
  17. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
  18. LOGames

    LOGames

    Joined:
    Sep 4, 2016
    Posts:
    19
    Thought I'd show what I've been working on with the engine. All super temporary at the moment, but it's getting somewhere.

     
    Grafos, Boom_Shaka and reuno like this.
  19. Fabioisriva

    Fabioisriva

    Joined:
    Feb 3, 2016
    Posts:
    15
    at the end I managed to integrate it, but it doesn't seem smooth yet I also understand that Cinemachine are in constant develoment phase,so meanwhile its better i put step aside until it works natively with corgi and i think @reuno has plan to integrate to corgi it self:)
     
  20. AxelBoltok

    AxelBoltok

    Joined:
    Jun 26, 2017
    Posts:
    10
    Hello, on the script Health, when i select Flicker Sprite on Hit i have a problem, it only turns red the first gameobject that it finds (my enemy have separated parts of the body head, legs, etc) how could i make so it flicks the entire enemy, Thanks!
     
  21. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @AxelBoltok > You'll need to extend the Health class to implement that specifically for setups that can't be guessed by the engine, such as yours.
     
  22. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Hi @reuno ,

    I'm still in Corgi Engine 4.5 since it juste impossible for me to upgrade with my current project. Sadly I got a save problem. I create my own progressmanager based on RetroAdventureProgressManager. When I play the game in the editor everything work fine, when my character take a upgrade, the upgrade is still loaded in the next scene.

    But When I build the game, nothing work... event the corgi engine event "levelCompleted" isn't trigger...when the same scene work fine in the editor.

    Do you have a solution ?

    Thanks
     
  23. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @Levrault > I've never heard of such an error, even on 4.5, and without more details (errors, exact chain of events and why the levelCompleted event wouldn't be fired) I can't guess what the problem is in your setup. I'd suggest comparing with the demo ones, assuming they're working, to see what you may have done differently. If the problem persists please use the support email, thanks.
     
  24. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Alright I will tried to add mores informations.

    First of all here my ProgressManager, it almost the same has the RetroAdventure one. I just add a hack to force a reset wihtout deleting the folder (since deleting the folder didn't seems to work in build mode)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MoreMountains.Tools;
    4. using System.Collections.Generic;
    5. using MoreMountains.InventoryEngine;
    6. using MoreMountains.CorgiEngine;
    7. using UnityEngine.SceneManagement;
    8. using Managers;
    9.  
    10. namespace Managers {
    11.   [System.Serializable]
    12.   /// <summary>
    13.   /// A serializable entity to store retro adventure scenes, whether they've been completed, unlocked, how many stars were collected, and which ones
    14.   /// </summary>
    15.   public class GameScene {
    16.     public string SceneName;
    17.     public bool collectedUpgrade;
    18.   }
    19.  
    20.   [System.Serializable]
    21.   /// <summary>
    22.   /// A serializable entity used to store progress
    23.   /// </summary>
    24.   public class Progress {
    25.     public bool Flower = false;
    26.     public bool Dress = false;
    27.     public bool Shoes = false;
    28.     public bool KnowForShoes = false;
    29.     public bool InitialFlower = false;
    30.     public bool InitialDress = false;
    31.     public bool InitialShoes = false;
    32.     public bool InitialKnowForShoes = false;
    33.   }
    34.  
    35.   /// <summary>
    36.   /// The ProgressManager class
    37.   /// </summary>
    38.   public class ProgressManager : Singleton<ProgressManager>, MMEventListener<CorgiEngineStarEvent>, MMEventListener<CorgiEngineEvent> {
    39.  
    40.     // flower unlocked
    41.     public bool Flower;
    42.     // shoes unlocked
    43.     public bool Shoes;
    44.     public bool KnowForShoes;
    45.     // dress unlocked
    46.     public bool Dress;
    47.  
    48.     /// the list of scenes that we'll want to consider for our game
    49.     public GameScene[] Scenes;
    50.  
    51.     public bool InitialFlower { get; set; }
    52.     public bool InitialDress { get; set; }
    53.     public bool InitialShoes { get; set; }
    54.     public bool InitialKnowForShoes { get; set; }
    55.  
    56.     protected const string _saveFolderName = "MMProgress";
    57.     protected const string _saveFileName = "Progress.data";
    58.  
    59.     /// <summary>
    60.     /// On awake, we load our progress and initialize our stars counter
    61.     /// </summary>
    62.     protected override void Awake() {
    63.       base.Awake();
    64.       LoadSavedProgress();
    65.     }
    66.  
    67.     /// <summary>
    68.     /// Saves the progress to a file
    69.     /// </summary>
    70.     protected virtual void SaveProgress() {
    71.       Progress progress = new Progress();
    72.       Flower = CoopManager.Instance.Flower;
    73.       Shoes = CoopManager.Instance.Shoes;
    74.       Dress = CoopManager.Instance.Dress;
    75.       KnowForShoes = CoopManager.Instance.KnowForShoes;
    76.       progress.Flower = CoopManager.Instance.Flower;
    77.       progress.Shoes = CoopManager.Instance.Shoes;
    78.       progress.Dress = CoopManager.Instance.Dress;
    79.       progress.KnowForShoes = CoopManager.Instance.KnowForShoes;
    80.       progress.InitialFlower = Flower;
    81.       progress.InitialShoes = Shoes;
    82.       progress.InitialDress = Dress;
    83.       progress.InitialKnowForShoes = KnowForShoes;
    84.  
    85.       Debug.LogError("----SaveProgress----");
    86.       Debug.LogError("flow " + progress.Flower);
    87.       Debug.LogError("shoes " + progress.Shoes);
    88.       Debug.LogError("dress " + progress.Dress);
    89.       Debug.LogError("know " + progress.KnowForShoes);
    90.  
    91.       SaveLoadManager.Save(progress, _saveFileName, _saveFolderName);
    92.     }
    93.  
    94.     /// <summary>
    95.     /// A test method to create a test save file at any time from the inspector
    96.     /// </summary>
    97.     protected virtual void CreateSaveGame() {
    98.       SaveProgress();
    99.     }
    100.  
    101.     /// <summary>
    102.     /// Loads the saved progress into memory
    103.     /// </summary>
    104.     protected virtual void LoadSavedProgress() {
    105.       if (SceneManager.GetActiveScene().name != "level1_intro") {
    106.         Progress progress = (Progress) SaveLoadManager.Load(_saveFileName, _saveFolderName);
    107.         if (progress != null) {
    108.           Flower = progress.Flower;
    109.           Shoes = progress.Shoes;
    110.           Dress = progress.Dress;
    111.           KnowForShoes = progress.KnowForShoes;
    112.           CoopManager.Instance.Flower = progress.Flower;
    113.           CoopManager.Instance.Shoes = progress.Shoes;
    114.           CoopManager.Instance.Dress = progress.Dress;
    115.           CoopManager.Instance.KnowForShoes = progress.KnowForShoes;
    116.           InitialDress = progress.InitialDress;
    117.           InitialShoes = progress.InitialShoes;
    118.           InitialFlower = progress.InitialFlower;
    119.           InitialShoes = progress.InitialKnowForShoes;
    120.  
    121.           Debug.LogError("----LoadProgress----");
    122.           Debug.LogError("flow " + progress.Flower);
    123.           Debug.LogError("shoes " + progress.Shoes);
    124.           Debug.LogError("dress " + progress.Dress);
    125.           Debug.LogError("know " + progress.KnowForShoes);
    126.  
    127.         } else {
    128.           InitialDress = CoopManager.Instance.InitialDress;
    129.           InitialFlower = CoopManager.Instance.InitialFlower;
    130.           InitialShoes = CoopManager.Instance.InitialShoes;
    131.           InitialShoes = CoopManager.Instance.InitialKnowForShoes;
    132.         }
    133.       } else {
    134.         Debug.LogError("----ForceReset----");
    135.         CoopManager.Instance.Flower = false;
    136.         CoopManager.Instance.Shoes = false;
    137.         CoopManager.Instance.Dress = false;
    138.         CoopManager.Instance.KnowForShoes = false;
    139.         InitialDress = CoopManager.Instance.InitialDress;
    140.         InitialFlower = CoopManager.Instance.InitialFlower;
    141.         InitialShoes = CoopManager.Instance.InitialShoes;
    142.         InitialShoes = CoopManager.Instance.InitialKnowForShoes;
    143.         SaveProgress();
    144.       }
    145.  
    146.  
    147.       CoopManager.Instance.InitUpgradeOnLoad();
    148.     }
    149.  
    150.     /// <summary>
    151.     /// Loads the saved progress into memory
    152.     /// </summary>
    153.     protected virtual void HackedReset() {
    154.  
    155.       Progress progress = new Progress();
    156.       Flower = CoopManager.Instance.InitialFlower;
    157.       Shoes = CoopManager.Instance.InitialShoes;
    158.       Dress = CoopManager.Instance.InitialDress;
    159.       KnowForShoes = CoopManager.Instance.InitialKnowForShoes;
    160.       progress.Flower = CoopManager.Instance.InitialFlower;
    161.       progress.Shoes = CoopManager.Instance.InitialShoes;
    162.       progress.Dress = CoopManager.Instance.InitialDress;
    163.       progress.KnowForShoes = CoopManager.Instance.InitialKnowForShoes;
    164.       progress.InitialFlower = Flower;
    165.       progress.InitialShoes = Shoes;
    166.       progress.InitialDress = Dress;
    167.       progress.InitialKnowForShoes = KnowForShoes;
    168.       SaveLoadManager.Save(progress, _saveFileName, _saveFolderName);
    169.  
    170.       CoopManager.Instance.InitUpgradeOnLoad();
    171.     }
    172.  
    173.     /// <summary>
    174.     /// When we grab an item event, we update our scene status accordingly
    175.     /// </summary>
    176.     /// <param name="corgiStarEvent">Corgi star event.</param>
    177.     public virtual void OnMMEvent(CorgiEngineStarEvent corgiStarEvent) {
    178.       foreach (GameScene scene in Scenes) {
    179.         if (scene.SceneName == corgiStarEvent.SceneName) {
    180.           scene.collectedUpgrade = true;
    181.         }
    182.       }
    183.  
    184.       SaveProgress();
    185.     }
    186.  
    187.     /// <summary>
    188.     /// When we grab a level complete event, we update our status, and save our progress to file
    189.     /// </summary>
    190.     /// <param name="gameEvent">Game event.</param>
    191.     public virtual void OnMMEvent(CorgiEngineEvent gameEvent) {
    192.       Debug.LogError("DetectEvent");
    193.  
    194.       switch (gameEvent.EventType) {
    195.         case CorgiEngineEventTypes.LevelComplete:
    196.           Debug.LogError("Saved event has been send");
    197.           SaveProgress();
    198.           break;
    199.         case CorgiEngineEventTypes.GameOver:
    200.           GameOver();
    201.           break;
    202.       }
    203.     }
    204.  
    205.     /// <summary>
    206.     /// This method describes what happens when the player loses all lives. In this case, we reset its progress and all lives will be reset.
    207.     /// </summary>
    208.     protected virtual void GameOver() {
    209.       ResetProgress();
    210.     }
    211.  
    212.     /// <summary>
    213.     /// A method used to remove all save files associated to progress
    214.     /// </summary>
    215.     public virtual void ResetProgress() {
    216.       SaveLoadManager.DeleteSaveFolder(_saveFolderName);
    217.     }
    218.  
    219.     /// <summary>
    220.     /// OnEnable, we start listening to events.
    221.     /// </summary>
    222.     protected virtual void OnEnable() {
    223.       this.MMEventStartListening<CorgiEngineStarEvent>();
    224.       this.MMEventStartListening<CorgiEngineEvent>();
    225.     }
    226.  
    227.     /// <summary>
    228.     /// OnDisable, we stop listening to events.
    229.     /// </summary>
    230.     protected virtual void OnDisable() {
    231.       this.MMEventStopListening<CorgiEngineStarEvent>();
    232.       this.MMEventStopListening<CorgiEngineEvent>();
    233.     }
    234.   }
    235. }
    236.  
    Here my updrage script, his role his to set new ability to the player and create CorgiEngineEvent to force file to save.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.Tools;
    5. using MoreMountains.CorgiEngine;
    6. using UnityEngine.Events;
    7. using UnityEngine.SceneManagement;
    8. using Prompt;
    9. using Managers;
    10.  
    11. namespace Interactions {
    12.  
    13.   /// <summary>
    14.   /// Unleash action and set animation
    15.   /// </summary>
    16.   [AddComponentMenu("Corgi Engine/Environment/Lever")]
    17.   public class Upgrade : PromptButtonActivated {
    18.     [Header("Trigged when used")]
    19.     /// the method that should be triggered when the key is used
    20.     public UnityEvent KeyAction;
    21.  
    22.     [Header("Upgrade settings")]
    23.     public string AbilityToEnable;
    24.     public string TargetedPlayer;
    25.     public int UpgradeId = 0;
    26.  
    27.     [Header("Dialogue settings")]
    28.     public DialogueZone DialogueZone;
    29.     public float timerBeforeFade = 1f;
    30.     protected Collider2D _collidingObject;
    31.     private Animator _animator;
    32.     private BoxCollider2D _boxCollider2D;
    33.     private SpriteRenderer _sprite;
    34.  
    35.     void Start() {
    36.       _animator = GetComponent<Animator>();
    37.       _sprite = GetComponent<SpriteRenderer>();
    38.       _boxCollider2D = GetComponent<BoxCollider2D>();
    39.  
    40.       if (CoopManager.Instance.GetProgressUpgradeStatus(AbilityToEnable)) {
    41.         gameObject.SetActive(false);
    42.       }
    43.     }
    44.  
    45.     /// <summary>
    46.     /// On enter we store our colliding object
    47.     /// </summary>
    48.     /// <param name="collider">Something colliding with the water.</param>
    49.     protected override void OnTriggerEnter2D(Collider2D collider) {
    50.       _collidingObject = collider;
    51.       if (_collidingObject.gameObject.GetComponent<Character>().PlayerID == TargetedPlayer) {
    52.         base.OnTriggerEnter2D(collider);
    53.       }
    54.     }
    55.  
    56.     /// <summary>
    57.     /// When the button is pressed, we check if we have a key in our inventory
    58.     /// </summary>
    59.     public override void TriggerButtonAction() {
    60.       if (!CheckNumberOfUses()) {
    61.         return;
    62.       }
    63.  
    64.       if (_collidingObject == null) { return; }
    65.  
    66.       StartCoroutine(HidePrompt());
    67.       TriggerKeyAction();
    68.       ZoneActivated();
    69.     }
    70.  
    71.     /// <summary>
    72.     /// Calls the method associated to the key action
    73.     /// </summary>
    74.     protected virtual void TriggerKeyAction() {
    75.       if (KeyAction != null) {
    76.         _animator.SetBool("Activated", true);
    77.         KeyAction.Invoke();
    78.         _boxCollider2D.enabled = false;
    79.       }
    80.     }
    81.  
    82.     /// <summary>
    83.     /// Call manager to upgrade player
    84.     /// </summary>
    85.     public void UpgradePlayer() {
    86.       CoopManager.Instance.UpgradePlayer(AbilityToEnable);
    87.       MMEventManager.TriggerEvent(new CorgiEngineStarEvent(SceneManager.GetActiveScene().name, UpgradeId));
    88.       MMEventManager.TriggerEvent(new CorgiEngineEvent(CorgiEngineEventTypes.LevelComplete));
    89.       MMEventManager.TriggerEvent(new MMGameEvent("Save"));
    90.     }
    91.  
    92.     public void AfterUpgrade() {
    93.       _sprite.enabled = false;
    94.       DialogueZone.GetComponent<BoxCollider2D>().enabled = true;
    95.       DialogueZone.StartDialogue();
    96.     }
    97.   }
    98. }
    99.  
    The problem happen only in build mode and I get no error... I try to debug everything but I just can said that corgi event just doesn't work in my setup. Here my build settings.

    upload_2018-10-21_15-33-34.png
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @Levrault > I don't know what's wrong with your scripts, and unfortunately I can't debug them for you just by looking at this. As I said, you might want to compare with the engine's examples, no changes made, and see what you may have done differently. And again, please use the support email if the problem persists.
     
  26. AxelBoltok

    AxelBoltok

    Joined:
    Jun 26, 2017
    Posts:
    10
    I see, just asked because i thought it was a common issue, i made a script (simple and not optimized yet) to do it in the meantime that is actually working, when the flicker coroutine is called i added
    Code (CSharp):
    1. gameObject.BroadcastMessage("Flick");
    then i created a new script that will be attached to the sons where i need the sprite to flick
    Code (CSharp):
    1.     private SpriteRenderer rend;
    2.     private Color initialColor;
    3.     private Color tempColor = new Color32(255, 20, 20, 255);
    4.     private int contador = 0;
    5.     private float time = 0f;
    6.  
    7.  
    8.     void Start () {
    9.         rend = GetComponent<SpriteRenderer>();
    10.         initialColor = rend.color;
    11.     }
    12.  
    13.     void Update() {
    14.         if(contador>0){
    15.             time += Time.deltaTime;
    16.             if (time < 0.05f){
    17.                 rend.color = tempColor;
    18.             }
    19.             if (time > 0.05f){
    20.                 rend.color = initialColor;
    21.             }
    22.             if(time > 0.1f){
    23.                 time = 0f;
    24.                 contador--;
    25.             }
    26.         }
    27.  
    28.  
    29.     }
    30.  
    31.     void Flick(){
    32.         contador = 5;
    33.     }
    As i said not fully optimized yet but it works, hopefully is usefull to someone :)
     
    Muppo likes this.
  27. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    Simple but effective. Thanks for sharing @AxelBoltok

    PS: That "contador" betray yourself, didn't know there was more spanish speaking people here ;)

    Edit: fixed a typo.
     
    Last edited: Oct 22, 2018
    AxelBoltok likes this.
  28. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    @reuno finally, after rolling back to unity 2018.2.6f, I was enable to make event fire again. But I got a last problem.

    On the awake function of my ProgressManager, I'm calling ResetProgess on the first level only to reset all saved data. But I don't know why, in builds mode, the folder doesn't seems to be deleted. I try to change admin permission of my exec but the problem seems to persist. Does it was an issue on corgi engine 4.5 ?

    Code (CSharp):
    1.     if (SceneManager.GetActiveScene().name == "level1_intro") {
    2.         Debug.LogError("Reset Progress");
    3.         ResetProgress();
    4.       } else {
    5.         LoadSavedProgress();
    6.       }
    Thanks
     
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @Levrault > Please use the support email.
    @AxelBoltok > Thanks a lot for sharing this. If you do a cleaned up version, I can add it to the extension repo if you want.
     
  30. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    663
    @reuno So I was wondering how coupled are the systems in the Corgi Engine. I am asking because I am looking to build a game that is more of an RPG in the platformer environment so systems like the inventory system, weapon system, dialog system, etc. are things that I am going to have very specific requirements for however building proper platformer controls is something I feel would take me way to long to understand and implement well.

    Is it possible to use only the physics / collision parts of the Corgi Engine but implement everything else custom (or use a different library if I think I need to like the ProCamera2D for example) or are the systems tightly coupled to each other where I would be fighting to do something like that?
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @ryanzec > I try to keep coupling to a minimum, to the limit that it doesn't become harder to use.
    The Inventory Engine is its own asset, so it really works on its own and has zero coupling with the Corgi Engine.
    It's absolutely possible to just use the controller (so collisions/forces) and do everything else on your own.
    Still, if you run into something where you think coupling could be reduced, just let me know and I'll see what I can do.
     
  32. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    663
    @reuno So I am trying to get a very basic example working without luck. I have a game object with a sprite and a box collidor, regidbody2d, CorgiController, Character, and Character Horizontal Movement script on it with layer of Player and another object with a sprite box coillidor with a layer of Platforms and the character properly fall onto the platform without going through after setting up the layers in the controller however when I press the A / D keys, not happens and sure what I am doing wrong (I looked at the Character Horizontal Movement script but did not see anything that was looking at input to move the character).
     
  33. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @ryanzec > Have you tried checking the doc and tutorials? They explain all there is to know about character creation. It's hard to guess what you're doing wrong here. I'd say check the tutorial/doc and compare with the many examples included in the package.
     
  34. AxelBoltok

    AxelBoltok

    Joined:
    Jun 26, 2017
    Posts:
    10
    Hello, i made a custom AI brain function and i have attached the Auto Respawn script with both bools on true, when i kill the AI and later i die, when the AI respawns AI Brain script is disabled, causing the AI to stop working properly (also damage on touch script), does anyone have the same problem?
     
  35. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    663
    @reuno, I got the minimal scene working, I was just missing the input manager component in my scene. I do have some questions / comments as it relates to stuff I saw in the minimum requirements video:

    1. The video make it seem like the GameManager is required however it only stores stuff as it related to live (maximum, current, and game over scene) however those really don't relate to my game as this game in really a RPG and not a platformer in the true sense, it just happens to play like a platformer from a visual / physics perspective. Am I go to run into any issue with the physics part of the engine without the game manager (my basic test worked fine without it but I am doing nothing more than move a character around that can jump).
    EDIT: It seems like if you don't have this it is also auto added to a new game object so my question on #2 applies here as well.

    2. The video makes mention that the GUIManager is not required however when I removed that and started the game, a game object called New Game Object was created that added the GUIManager to the scene (a game object of the same name was also added to the scene in the video when you did it). Again, the way the GUI looks to be setup is something that will not be able to use as the GUI for my game is going to be very different than that of a standard platformer game. Can I assume that if the GUIManager has nothing set on it, it should not cause a problem? If so, it would be cool to not have that automatically created (but again, if it won'y break anything, than I am not too worried about it).

    Outside of that, everything for my basic testing seems pretty good as least for the prototype stage I am in.

    Thanks for you quick replies.
     
    Last edited: Oct 23, 2018
  36. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    663
    @reuno So this it something weird to me that I noticed and not sure it is intended behaviour or not. I setup the maximum slope angle for my corgi controller script to be 60 and as far as being able to walking on slopes below that and not able to walk on slopes above that, that all worked as expected however the character is still able to jump on a slope greater than 60 and not fall down:

    corgi-engine-slope-issue.png

    Is this the expected default behaviour? If so, it there a way to make sure if the player jumps on a slope greater than the defined maximum slope angle, the player will automatically slide down (as well as not be able to jump on angle greater than the defined maximum slope angle)?
     
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @AxelBoltok > You probably have your character's Health set to destroy on death.
    @ryanzec > The game manager has nothing to do with physics. If it gets "auto added" that's probably because something in your scene is referencing it. If you feel like you absolutely don't want it, code it out. Same thing for the GUIManager. And yes, that's the expected behavior for slopes. There's no slide down ability. You can check a full list of abilities on the asset's page. Please use the support email if you have more questions, thanks.
     
  38. admadea

    admadea

    Joined:
    Oct 26, 2017
    Posts:
    4
    Hey, thanks again for your help back in September, now I need help again. I'm using my modified dash ability as an attack, but I can't seem to get knockback on the players end of things working. Enemies respond properly, but I think the dash ability's movement is overriding the knockback from the DamageOnTouch script? Here's my code, in case the problem stems from something I've written.
    Code (CSharp):
    1. using MoreMountains.CorgiEngine;
    2. using System.Collections;
    3. using UnityEngine;
    4.  
    5.  
    6. [RequireComponent(typeof(MoreMountains.CorgiEngine.DamageOnTouch))]
    7. [AddComponentMenu("Corgi Engine/Character/Abilities/Character Dash")]
    8. public class DashAttack : MoreMountains.CorgiEngine.CharacterDash
    9. {
    10.     public float vertDashForce = 1f;
    11.  
    12.     private DamageOnTouch damageOnTouch;
    13.  
    14.  
    15.  
    16.     // Use this for initialization
    17.     protected override void Start()
    18.     {
    19.         base.Start();
    20.  
    21.  
    22.     }
    23.  
    24.     protected void Awake()
    25.     {
    26.         damageOnTouch = GetComponent<DamageOnTouch>();
    27.  
    28.        
    29.     }
    30.  
    31.     protected void FixedUpdate()
    32.     {
    33.         if (_movement.CurrentState != CharacterStates.MovementStates.Dashing && damageOnTouch.enabled)
    34.         {
    35.             damageOnTouch.enabled = false;
    36.         }
    37.     }
    38.  
    39.  
    40.     //Majority of overrides start here
    41.  
    42.     protected override void Initialization()
    43.     {
    44.         base.Initialization();
    45.  
    46.     }
    47.  
    48.     protected override void HandleInput()
    49.     {
    50.         base.HandleInput();
    51.     }
    52.  
    53.     public override void ProcessAbility()
    54.     {
    55.         base.ProcessAbility();
    56.         // If the character is dashing, we cancel the gravity
    57.        /* if (_movement.CurrentState == CharacterStates.MovementStates.Dashing)
    58.         {
    59.             _controller.GravityActive(false);
    60.             _controller.SetVerticalForce(0);
    61.         }*/
    62.  
    63.        
    64.         // we reset our slope tolerance if dash didn't end naturally
    65.         if ((!_dashEndedNaturally) && (_movement.CurrentState != CharacterStates.MovementStates.Dashing))
    66.         {
    67.             _dashEndedNaturally = true;
    68.             _controller.Parameters.MaximumSlopeAngle = _slopeAngleSave;
    69.         }
    70.  
    71.  
    72.     }
    73.  
    74.     public override void StartDash()
    75.     {
    76.         base.StartDash();
    77.     }
    78.  
    79.     public override void InitiateDash()
    80.     {
    81.         base.InitiateDash();
    82.         if (!damageOnTouch.enabled)
    83.         {
    84.             damageOnTouch.enabled = true;
    85.         }
    86.     }
    87.  
    88.     protected override IEnumerator Dash()
    89.     {
    90.         // if the character is not in a position where it can move freely, we do nothing.
    91.         if (!AbilityPermitted
    92.             || (_condition.CurrentState != CharacterStates.CharacterConditions.Normal))
    93.         {
    94.             yield break;
    95.         }
    96.  
    97.         // we initialize our various counters and checks
    98.         _startTime = Time.time;
    99.         _dashEndedNaturally = false;
    100.         _initialPosition = this.transform.position;
    101.         _distanceTraveled = 0;
    102.         _shouldKeepDashing = true;
    103.         _dashDirection = _character.IsFacingRight ? 1f : -1f;
    104.         _computedDashForce = DashForce * _dashDirection;
    105.        
    106.  
    107.         // we prevent our character from going through slopes
    108.         _slopeAngleSave = _controller.Parameters.MaximumSlopeAngle;
    109.         _controller.Parameters.MaximumSlopeAngle = 0;
    110.  
    111.         // we keep dashing until we've reached our target distance or until we get interrupted
    112.         while (_distanceTraveled < DashDistance && _shouldKeepDashing && _movement.CurrentState == CharacterStates.MovementStates.Dashing)
    113.         {
    114.             _distanceTraveled = Vector3.Distance(_initialPosition, this.transform.position);
    115.  
    116.             // if we collide with something on our left or right (wall, slope), we stop dashing, otherwise we apply horizontal force
    117.             if ((_controller.State.IsCollidingLeft || _controller.State.IsCollidingRight))
    118.             {
    119.                 _shouldKeepDashing = false;
    120.                 _controller.SetForce(Vector2.zero);
    121.             }
    122.             else
    123.             {
    124.                 if (_distanceTraveled <= (DashDistance / 4f) && _movement.CurrentState == CharacterStates.MovementStates.Dashing)
    125.                 {
    126.                     //If the dash is in it's first third
    127.                     //It should disable Gravity, and apply a vertical force for the duration
    128.                     //Else if it is greater and gravity isn't enabled, enable gravity
    129.                     Debug.Log("Dash is in first Fourth");
    130.  
    131.                     _controller.GravityActive(false);
    132.                     _controller.SetVerticalForce(vertDashForce);
    133.                 }
    134.                 else if (_distanceTraveled >= (DashDistance / 4f) && _movement.CurrentState == CharacterStates.MovementStates.Dashing)
    135.                 {
    136.                     _controller.GravityActive(true);
    137.                    
    138.                 }
    139.  
    140.                 _controller.SetHorizontalForce(_computedDashForce);
    141.             }
    142.             yield return null;
    143.         }
    144.  
    145.         StopDash();
    146.     }
    147.  
    148.     public override void StopDash()
    149.     {
    150.         base.StopDash();
    151.  
    152.         if (damageOnTouch.enabled)
    153.         {
    154.             damageOnTouch.enabled = false;
    155.         }
    156.     }
    157.  
    158.     protected override void InitializeAnimatorParameters()
    159.     {
    160.         base.InitializeAnimatorParameters();
    161.     }
    162.  
    163.     public override void UpdateAnimator()
    164.     {
    165.         base.UpdateAnimator();
    166.     }
    167.  
    168.  
    169.  
    170. }
    Also, another quick question; how would I introduce the ability for the player to "charge" the dash while the button is held down, up until a limit? I plan on adding a few powerup into the game that affect things like max charge distance, height of dash, charge time, and damage.
     
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @admadea > I can't debug your code for you, especially without context :)
    I'd suggest tracking the chain of events to understand what's happening. There are multiple examples of fast moving objects applying knockback, projectiles for example, I'd start with that. As for charge, you have an example of it in the Weapon class.
     
  40. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    218
    Are enemies with the Character Fly ability immune to knockback? I can't seem to get it to work on them unless I deactivate the ability/permission
     
  41. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    When respawn, camera is not teleported to the last check point. Didn't really noticed it until I have set long distance checkpoints.
    Can I suggest this camera reset works as teleport does on a future release? (instant teleport and / or fade to black features)

    Thanks.
     
  42. ThoZ

    ThoZ

    Joined:
    Apr 21, 2013
    Posts:
    29
    managed to implement my first custom character abilite :)
    WallClimb
     
    MisterDeum and Mindjar like this.
  43. ThoZ

    ThoZ

    Joined:
    Apr 21, 2013
    Posts:
    29
    @Muppo:

    The Camera Controller has a boolean Instant Reposition Camera on Respawn
    Is this what you are looking for?
     
  44. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    I know, I requested it myself some time ago to @reuno and I want to apologize, it wasn't the camera script fault but my custom one, I double checked this time. However, the fade to black addition could be nice, I guess.

    @ThoZ That WallClimb looks neat!
    How did you approached it?
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @ThoZ > That's a great ability, good job! (And thanks for pointing to the right setting!)
    @Muppo > You can add the fade to black by extending, it's a one liner :)
     
  46. ThoZ

    ThoZ

    Joined:
    Apr 21, 2013
    Posts:
    29
    @Muppo
    First i thought about the mechanic (wallclimb, but not forever). It has a resource (kind of like ammo), when it is empty, you can't wallclimb anymore and it gets canceled.

    The wallclimbing itself is a combination of WallClinging and the Ladder Script. Also had to overwrite the WallJump Method, so it is possible to walljump out of the new WallClimbing State.
     
    Muppo, Boom_Shaka and reuno like this.
  47. NEHWind2

    NEHWind2

    Joined:
    Jan 7, 2016
    Posts:
    23
    Hello everyone!

    I'm making a game modeled after Mega Man X and the first thing that my testers mention is always that my character can't shoot outwards while clinging to a wall. I was just curious if anyone has ever written an extension allowing that, or if anyone has any advice on how to make it happen myself. I know it's a long shot but I'm no programmer so I thought I'd ask. Currently characters will shoot straight into the wall while clinging, which plays the sound and spawns the shot for a brief moment, so even a way to disable the ability to shoot while using Wall Cling would be helpful! If anyone has any ideas I would be very thankful to hear them!

    @reuno said it was on the list to be added officially a bit ago but since I've never seen anyone else request it I figure it's pretty low priority. It's a very specific feature so that's natural, but I don't think it's ever been brought up here for others to show support for the feature if they're interested in it. A lot of fun new enemies, bosses and creative level designs could be possible if players can attack from a wall, now more than ever with the new AI system!
     
  48. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    210
    @reuno > It took more than one line but looking at the fading coroutines on the teleport, finally achieve what I want. It goes easier everyday to work with your code.

    @ThoZ > Thanks mate, in case I need it, I'll try your ideas.

    @NEHWind2 > Just suppouse, What if you override weapon direction when player is wallcling?
     
    reuno likes this.
  49. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,079
    @NEHWind2 > As @Muppo said, you need to override the weapon's direction while wallclinging.
    @Muppo > That's just you getting better and better :)
     
    Muppo likes this.
  50. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    218
    I'd appreciate an answer