Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[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. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29

    I'm a lousy programmer but I made this script to create a timer and kill the player whenever the time is 0.
    If someone has a more enlightened mind please share a better timer that kills the player when the time is 0.
    For now this is functional, but since I'm not a programmer I don't know how to improve it.
    To use it, you must create a (simple) text object in the canvasUI and set the font size to make it look like you want to assign the CountDown.cs script and set the ls minutes and seconds. and it would be everything





    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using MoreMountains.CorgiEngine;
    6. using MoreMountains.Tools;
    7.  
    8. public class CountdownTimer : MonoBehaviour
    9. {
    10.     public Text timerText;
    11.     public int minutes;
    12.     public int seconds;
    13.     public GameObject player;
    14.     private float initialTime;
    15.  
    16.     public bool gameStarted = false;
    17.     private float startTime;
    18.     private float currentTime;
    19.     public bool timerFinished = false;
    20.  
    21.     void Start()
    22.     {
    23.         StartCoroutine(FindPlayer());
    24.         timerFinished = false;
    25.         gameStarted = true;
    26.         initialTime = minutes * 60 + seconds;
    27.         currentTime = initialTime;
    28.     }
    29.  
    30.     IEnumerator FindPlayer()
    31.     {
    32.         while (player == null)
    33.         {
    34.             player = GameObject.Find("Player");
    35.             yield return null;
    36.         }
    37.         startTime = Time.time;
    38.         currentTime = minutes * 60 + seconds;
    39.     }
    40.  
    41.  
    42.     void RestartTimer()
    43.     {
    44.         timerFinished = false;
    45.         currentTime = initialTime;
    46.     }
    47.  
    48.     void Update()
    49.     {
    50.  
    51.         currentTime -= Time.deltaTime;
    52.         int minutes = (int)currentTime / 60;
    53.         int seconds = (int)currentTime % 60;
    54.         timerText.text = minutes.ToString("00") + ":" + seconds.ToString("00");
    55.  
    56.  
    57.         if (currentTime <= 0 && timerFinished == false && gameStarted)
    58.         {
    59.             timerText.text = "00:00";
    60.             if (player == null)
    61.             {
    62.                 return;
    63.             }
    64.             Character character = player.GetComponent<Character>();
    65.             if (character == null)
    66.             {
    67.                 return;
    68.             }
    69.             if (character.CharacterType != Character.CharacterTypes.Player)
    70.             {
    71.                 return;
    72.             }
    73.             if (character.ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead)
    74.             {
    75.                 character.CharacterHealth.Kill();
    76.                 RestartTimer();
    77.             }
    78.         }
    79.     }
    80. }
    81.  
     
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    Helienio likes this.
  3. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29
    reuno likes this.
  4. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29
    I am a designer, not a programmer. Corgi Engine is an easy-to-use engine for me, who am only a hobbyist in C# programming. It is facilitating the development of my game a lot. Yes, there are some missing things and details to add, as there are many ideas that one can add, but one can make the effort and program the missing components. It is still complicated for me, but I do my best to develop the missing components.

    I don't know the creator and I've never talked to him, but his CorgiEngine is great.

    I will start sharing my component ideas here to improve this asset. If the creator finds it convenient, he can use these ideas to implement them in future upgrades and make what is already great even greater, making the lives of many who use this 2D and 2.5D development tool easier.
     
  5. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    xacarana and Helienio like this.
  6. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29
    am using version 2.5D of Corgi Engine and, unlike the 2D version, it is still very limited compared to all the examples in the 2D version.

    As I develop my game, I will share everything I create to improve it here.

    I'll start by sharing what I think is very important in a game: identifying the type of ground and emitting a sound according to the ground being walked on.

    To do this, I have created two scripts: one that goes on the platform that the character will walk on (GroundType.cs). In this script, we record all the types of ground that the character will walk on.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GroundType : MonoBehaviour
    6. {
    7.     public GroundTypeEnum groundType;
    8. }
    9.  
    10. public enum GroundTypeEnum
    11. {
    12.     Wood,
    13.     Metal,
    14.     Grass,
    15.     Dirt,
    16.     Concrete,
    17.     Water
    18. }
    19.  
    To implement it, you will have to create a Tag called "Ground" and assign it to the platform. You will then choose what type of ground it is. That's it.

    The other script is FootStepSound.cs.


    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using static GroundTypeEnum;
    6. public class FootStepSound : MonoBehaviour
    7. {
    8.     public AudioClip[] woodFootStepSounds;
    9.     public AudioClip[] metalFootStepSounds;
    10.     public AudioClip[] grassFootStepSounds;
    11.     public AudioClip[] dirtFootStepSounds;
    12.     public AudioClip[] concreteFootStepSounds;
    13.     public AudioClip[] waterFootStepSounds;
    14.     public AudioSource audioSource;
    15.     public float timeBetweenSteps = 0.5f;
    16.     private float lastStepTime;
    17.     private bool isWalking;
    18.     private GroundTypeEnum lastGroundType;
    19.     private void Start()
    20.     {
    21.         isWalking = false;
    22.     }
    23.     private void Update()
    24.     {
    25.         if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
    26.         {
    27.             isWalking = true;
    28.         }
    29.         else
    30.         {
    31.             isWalking = false;
    32.             audioSource.Stop();
    33.         }
    34.     }
    35.     private void PlayFootStepSound()
    36.     {
    37.         if (lastGroundType == GroundTypeEnum.Wood)
    38.         {
    39.             audioSource.clip = woodFootStepSounds[Random.Range(0, woodFootStepSounds.Length)];
    40.             audioSource.Play();
    41.         }
    42.         else if (lastGroundType == GroundTypeEnum.Metal)
    43.         {
    44.             audioSource.clip = metalFootStepSounds[Random.Range(0, metalFootStepSounds.Length)];
    45.             audioSource.Play();
    46.         }
    47.         else if (lastGroundType == GroundTypeEnum.Grass)
    48.         {
    49.             audioSource.clip = grassFootStepSounds[Random.Range(0, grassFootStepSounds.Length)];
    50.             audioSource.Play();
    51.         }
    52.         else if (lastGroundType == GroundTypeEnum.Dirt)
    53.         {
    54.             audioSource.clip = dirtFootStepSounds[Random.Range(0, dirtFootStepSounds.Length)];
    55.             audioSource.Play();
    56.         }
    57.         else if (lastGroundType == GroundTypeEnum.Concrete)
    58.         {
    59.             audioSource.clip = concreteFootStepSounds[Random.Range(0, concreteFootStepSounds.Length)];
    60.             audioSource.Play();
    61.         }
    62.         else if (lastGroundType == GroundTypeEnum.Water)
    63.         {
    64.             audioSource.clip = waterFootStepSounds[Random.Range(0, waterFootStepSounds.Length)];
    65.             audioSource.Play();
    66.         }
    67.     }
    68.     private void ApplyRandomPitchAndVolume()
    69.     {
    70.         float randomPitch = Random.Range(0.9f, 1f);
    71.         float randomVolume = Random.Range(0.1f, 0.5f);
    72.         audioSource.pitch = randomPitch;
    73.         audioSource.volume = randomVolume;
    74.     }
    75.     private void OnCollisionEnter2D(Collision2D collision)
    76.     {
    77.         if (collision.gameObject.CompareTag("Ground") && isWalking && Time.time > lastStepTime + timeBetweenSteps)
    78.         {
    79.             GroundType groundType = collision.gameObject.GetComponent<GroundType>();
    80.             lastGroundType = groundType.groundType;
    81.             lastStepTime = Time.time;
    82.             if (isWalking)
    83.             {
    84.                 ApplyRandomPitchAndVolume();
    85.                 PlayFootStepSound();
    86.             }
    87.         }
    88.     }
    89. }
    90.  
    To use it, you will need to create an empty object in the root of the Player object, change its name to FootStepSFX, and assign an AudioSource component to it. Configure the OUTPUT to locate SFX and choose this option from the MMSoundManagerAudioMixer. Now, you need to create an empty object at the left foot of the character, rename the object to LeftFootSFX, and assign a Circle Collider 2D component to it. You also need to assign a Rigidbody 2D component to it and leave the constraints as Freeze Position X, Y, and Freeze Rotation Z. Do the same for the right foot of the character.

    Now, assign the FootStepSound.cs to the object of each foot, and you will have to configure the sounds for each type of ground by choosing the sound you want. In the AudioSource option, you should choose the object you created at the beginning, FootStepSFX.

    With this, when you walk your 3D character, there should be a different type of sound for each ground you choose in your platforms with the Ground tag that you have the GroundType.cs assigned to.


    Remember to adjust the radius of the Circle Collider 2D on each LeftFootSFX and RightFootSFX object, and if necessary, also the animation, as sometimes in the animation the foot doesn't move away from the ground much.

    Friends, as I said, I'm not a C# programmer, I'm an enthusiast. If you can improve this code and share it, I would appreciate it.
     
    Last edited: Jan 31, 2023
  7. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    Helienio likes this.
  9. Helienio

    Helienio

    Joined:
    Sep 11, 2014
    Posts:
    29
    Hello, I am trying without achievements, read and alter the points of the game. I need help, how can I read and alter via script the points of the game?
    The documentation is very extensive and I have not found a method to alter the points of the game and add more points according to the events I want to create.
     
  10. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    Helienio likes this.
  11. Shinyshoes

    Shinyshoes

    Joined:
    Oct 12, 2021
    Posts:
    3
    Hello reuno, are there any news about a "metroid style map" ?
     
  12. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Shinyshoes > It's on my todo list, but it hasn't received a lot of votes so far compared to most other features. It's also something that extremely dependent on your art pipeline / level design, so hard to provide something of value in a generic way, it's highly contextual.
     
  13. Shinyshoes

    Shinyshoes

    Joined:
    Oct 12, 2021
    Posts:
    3
    Thanks for your reply. What you already deliver with this engine is remarkable as is.
     
    reuno likes this.
  14. unity_hS_2gsK-UZa-kQ

    unity_hS_2gsK-UZa-kQ

    Joined:
    Jan 25, 2023
    Posts:
    1
    I want to ask how to use the function of GrabCarryAndThrow, I can't succeed in the RetroPush example, nothing happens when I press e
     
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @unity_hS_2gsK-UZa-kQ > That's strange, I'm not aware of any issue with grab/carry at the moment. These steps should work : open the RetroPush demo scene, move right, jump on the little green cube, press E.

    If your issue persists, don't hesitate to provide a bit more info about how exactly you're testing.
     
  16. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    @reuno I searched the forum but couldnt find a reference. Im setting the endgame conditions to all AI being killed but cant find what to call. Substituting the character type to from player (which works fine) to AI didnt work nor did my AI detector class. Could you please point me in the right direction
    Thank you
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Sofiel > I'm not sure what you mean by "Substituting the character type to from player"? There's no feature like the one you describe in the engine, so it'd be something you'd handle with a new class. How to do it would depend on your exact specs, but it could be as simple as keeping a list of your AIs, and once they're all dead, load a new scene.
     
  18. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    thank you @reuno an array should work then. Thank you, have a great day
     
    reuno likes this.
  19. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    @reuno does the inventory character identifier work the same in Corgi Engine for multiplayer as it does in the TopDown Engine? I cant get the second player to get the itempickers or the weapons unles i make a specific item picker for the second inventory

    Thanks
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Sofiel > Yes, it works exactly the same as in TDE. You'll want to have one inventory per character (usually all named the same, but different PlayerID), and on each character a CharacterInventory referencing that same inventory name, and an InventoryCharacterIdentifier with the correct PlayerID (Player1, Player2, etc).
     
  21. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Hi reuno,im making a shop system. I added some codes to enter the shop page by inheriting KeyOperatedZone. And added a price variables to the InventoryItem.cs.So a ItemId called ”Money“can be currency. A new method of "RemoveItemByID" is added in the Inventory script. When the character purchases items, he can remove ”Money“ items by finding whether there is currency in the character's inventory, However, I encountered a problem when the character want to selling items.
    What should I do if I want to add inventory items according to ItemID?
    Please give some tips and suggestions.
     
  22. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
  23. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    I'm not a programmer, but after many experiments, I finally found a solution to manually add a monetary item in the store inventory. If player want to sell the items in the character inventory to exchange for monetary items, just need to add the quantity in the store inventory to the character inventory.LooksLikeThis:
    Code (CSharp):
    1.  public void OnSellButtonClick()
    2.     {
    3.         var slot = InventoryDisplay.CurrentlySelectedInventorySlot();
    4.         if (slot == null) return;
    5.         var slotItem = InventoryDisplay.TargetInventory.Content[slot.Index];
    6.         if (InventoryItem.IsNull(slotItem))
    7.             return;
    8.         var quantity = slotItem.Quantity;
    9.  
    10.         //counting price
    11.         int sellPrice = slotItem.CoinValue;
    12.         int totalSellPrice = sellPrice * quantity;
    13.  
    14.         // find coin item at shop
    15.         InventoryItem coinItem = null;
    16.         foreach (InventoryItem item in SellDisplay.TargetInventory.Content)
    17.         {
    18.             if (item != null && item.ItemID == "Coin")
    19.             {
    20.                 coinItem = item;
    21.                 break;
    22.             }
    23.         }
    24.  
    25.        
    26.         if (coinItem != null)
    27.         {
    28.             // add coin to player inventory
    29.             InventoryDisplay.TargetInventory.AddItem(coinItem, totalSellPrice);
    30.         }
    31.         InventoryDisplay.TargetInventory.RemoveItem(slot.Index, quantity);
    32.         InventoryDisplay.SetupInventoryDisplay();
    33.         Debug.Log("item sold!");
    34.     }
     
    reuno likes this.
  24. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Hello reuno.Why does the AI reload but cannot shoot the bullet after consuming the ammunition in the magazine for the first time? The enemy AI mounts the AIActionShoot component. Holds MagazineBased weapons, but I see that the weapons held by the enemy have not been updated to match the MagazineSize after the CurrentLoadedAmmo has been reloaded. This problem didn't happen to players, who could reload the weapon without the WeaponAmmo component in an unlimited amount of reload-shooting action, but AI couldn't.
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @wechat_os_Qy0z_aF7Nfhquhava38GLxUWU > I'm not sure I understand your setup. If the issue persists, don't hesitate to use the support form and provide steps to reproduce your issue, I'll be happy to have a look for you.
     
  26. Marboul

    Marboul

    Joined:
    Jun 26, 2020
    Posts:
    5
    Hi everyone ! First I want to thank you @reuno for this amazing engine ! I'm creating a 2D platformer coop game for my kids and I wanted to know if it is possible to stop character the most advanced on the right when it goes too far. For now the camera is zooming out too far and character are very small. What I'm trying to do is a sort of pause to wait for second character late. If you have a solution it would be so perfect !!! Thanks a lot for your help !
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Marboul > Put a collider on the right hand side of your screen. See one way level demo scenes for an example of something similar.
     
  28. Marboul

    Marboul

    Joined:
    Jun 26, 2020
    Posts:
    5
    Thanks a lot @reuno ! It seems that it is working only for player1. If player 2 is first, it doesn't work. Maybe, I've missed something.
     
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Marboul > Just if it wasn't clear : one way levels are an example of something like what you'd need to implement for that feature, they don't handle multiple characters, only one. You'd need to create a class, possibly inspired by it, that matches your specs.
     
  30. Marboul

    Marboul

    Joined:
    Jun 26, 2020
    Posts:
    5
    That's more clear. Thanks a lot @reuno
     
    reuno likes this.
  31. jzwicker-sd

    jzwicker-sd

    Joined:
    Jul 9, 2019
    Posts:
    4
    I found the extensions repo, how do I install these please?,
    I didn't find the info within the Readme.md nor the FAQs
     
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @jzwicker-sd > Usually you'll want to clone the repo (or download its contents), and copy the scripts you're interested in in your project. The details differ from script to script, they're created by the community.
     
    jzwicker-sd likes this.
  33. panost713

    panost713

    Joined:
    Feb 13, 2022
    Posts:
    5
    Hello,

    I used Corgi Engine to create a single screen arcade style platformer where the goal is to destroy as many enemies as you can. Instead of loading a game over screen, I'd rather have it just display the score you received and then have a button asking the player if they want to replay. Is there an easy way to do this with the Corgi Game Manager or would I have to script my own?
     
  34. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
  35. panost713

    panost713

    Joined:
    Feb 13, 2022
    Posts:
    5
    What about keeping the points from the previous level on the new game over screen? Is that possible?
     
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @panost713 > Yes, everything's possible, you make your own rules.
    The GameManager API has methods you can use to manipulate points, adding or resetting them as you please.
     
  37. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Hey, Reuno! Does the engine handle layered animations for 3D models, like shooting while running seamlessly? Like a run and gun game like MegaMan or Contra.
     
  38. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @Guideborn > No, the engine doesn't, but it doesn't have to, because Unity does :)
    All the engine does is update a number of animation parameters (https://corgi-engine-docs.moremountains.com/animations.html), and then you're free to use these in your Animators any way you want. So anything that Unity offers in that regard can be done, including layered animations.
     
  39. panost713

    panost713

    Joined:
    Feb 13, 2022
    Posts:
    5
    Thanks. :)

    I managed to get the points to display on the game over scene.

    However, when the game navigates to the main menu, I would like the points to reset. I've been playing around with the API but not luck. Is there a way to reset the points as soon as a particular scene plays? Thank you for the amazing engine and responding so quickly last time.
     
  40. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @panost713 > Yes, as mentioned previously, the GameManager API has methods you can you use to set points. Call SetPoints(0) when your scene loads.
     
  41. panost713

    panost713

    Joined:
    Feb 13, 2022
    Posts:
    5
    I've tried multiple ways but nothing seems to work. Excuse me because I'm still fairly new to C#.

    I want to get it to work as soon as a checkpoint loads (in this case, the game start.)

    I tried putting SetPoints to 0 when the LevelStart checkpoint begins, but the points are still left from the previous game. I'm at a loss for what to do. What can I do?

     
  42. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @panost713 > You're using an inspector binding to an object that will be out of scope, that reference won't be valid.
    Use code instead, call GameManager.Instance.SetPoints. Don't rely on unity events for something like this if you don't have a clear picture of scoping / object life cycles (GameManager is a persistent singleton).
     
  43. panost713

    panost713

    Joined:
    Feb 13, 2022
    Posts:
    5
    This fixed my issue. Thank you so much! I didn't have "instance" in my code.
     
    reuno likes this.
  44. SupremeSmash

    SupremeSmash

    Joined:
    Nov 30, 2018
    Posts:
    30
    Not a coder but wanted to give it a try, but having a slight issue when attaching it to a corgi engine created character. The script uses a circle collider to check if the gameobject is colliding with a cloud. If the gameobject is colliding with a cloud, the script sets a flag to make the character fall through the cloud. While the character is falling through the cloud, the script applies a downward force to the character's Rigidbody2D component to make them slowly fall through the cloud. When the character exits the cloud, the script stops applying the downward force and resets the character's velocity to zero.

    It works when I attach the script to a game object in the scene, however when I attach it to my character created with the corgi engine, it recognises I am on a cloud or have left the cloud, but doesn't apply the fall speed.

    If anyone could point me in the right direction, that would be much appreciated


    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class CloudFall : MonoBehaviour
    4. {
    5.     [SerializeField] private float fallSpeed = 2f;
    6.     [SerializeField] private float cloudCheckRadius = 1f;
    7.     [SerializeField] private LayerMask cloudLayer;
    8.  
    9.     private Rigidbody2D rb2d;
    10.     private bool isFallingThroughCloud = false;
    11.  
    12.     private void Start()
    13.     {
    14.         rb2d = GetComponent<Rigidbody2D>();
    15.     }
    16.  
    17.     private void FixedUpdate()
    18.     {
    19.         if (isFallingThroughCloud)
    20.         {
    21.             rb2d.velocity = new Vector2(rb2d.velocity.x, -fallSpeed);
    22.             CheckForCloud();
    23.         }
    24.     }
    25.  
    26.     private void CheckForCloud()
    27.     {
    28.         Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, cloudCheckRadius, cloudLayer);
    29.         if (hits.Length > 0)
    30.         {
    31.             foreach (Collider2D hit in hits)
    32.             {
    33.                 if (hit.gameObject.CompareTag("Cloud"))
    34.                 {
    35.                     Debug.Log("Player is on a cloud.");
    36.                     return;
    37.                 }
    38.             }
    39.         }
    40.  
    41.         // No cloud found, stop falling through cloud
    42.         isFallingThroughCloud = false;
    43.         rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
    44.         Debug.Log("Player is not on a cloud.");
    45.     }
    46.  
    47.     private void OnCollisionEnter2D(Collision2D other)
    48.     {
    49.         if (other.gameObject.CompareTag("Cloud"))
    50.         {
    51.             isFallingThroughCloud = true;
    52.         }
    53.     }
    54.  
    55.     private void OnCollisionExit2D(Collision2D other)
    56.     {
    57.         if (other.gameObject.CompareTag("Cloud"))
    58.         {
    59.             isFallingThroughCloud = false;
    60.             rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
    61.             Debug.Log("Player has left the cloud.");
    62.         }
    63.     }
    64. }
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @SupremeSmash > That's normal, the engine doesn't use physics (that's its main feature), so applying forces to a character's rigidbody won't do anything. Instead, you'll want to target the CorgiController's API to add or set forces. You can see examples of that in pretty much every ability in the engine. For example, you could look at the CharacterJetpack ability and how it uses SetVerticalForce, it's a fairly similar use case.

    Note that there are already similar components in the engine, such as the CorgiControllerOverride, which lets you change gravity (and other settings) inside an area. Would probably be a good fit for your cloud. See the FeaturesPlatforms demo scene for an example of it in action.
     
    SupremeSmash likes this.
  46. SupremeSmash

    SupremeSmash

    Joined:
    Nov 30, 2018
    Posts:
    30
    Thanks for the quick response Reuno, I will have a look at the character ability scripts
     
    reuno likes this.
  47. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Hello! I have a question. In a run and gun game, like say Mega Man or Contra, the character can run, and they can run while shooting. And when you switch between these two states, the animation is seamless. Meaning that when switching, the next animation loop starts at the point where the previous one left off, rather than starting from the beginning, which would produce a noticeable hiccup in the appearance of the running cycle. Does this engine handle this, or how would someone handle that in this engine?
     
  48. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @brittany > That's not something the engine handles, that's just something you'd setup in your animator.
    Typically, you'd use separate sprites, blend trees or animation masks for that.
     
    brittany likes this.
  49. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    The way I do it when I'm not using Corgi Engine is like this:
    If(anim.GetCurrentAnimatorClipInfo(0)[0].clip.name == "PlayerRunning")
    {
    anim.Play("PlayerShootRunning", -1, anim.GetCurrentAnimatorStateInfo(0).normalizedTime); //this starts the new animation at the time the previous animated was at)
    }
    else
    {
    anim.Play("PlayerShootRunning"); //else just start it from the beginning
    }

    Would it be easy for me to make this change somewhere in the engine or would it cause a lot of problems?
     
  50. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,905
    @brittany > The engine doesn't do any animation, Unity does. All the engine does is update animation parameters.
    It also doesn't play animations like that, instead, it uses Mecanim. I'd recommend looking at blend trees, it's the most common way to handle what you describe, and it's simpler, more powerful and versatile than your code above.
     
    brittany likes this.