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

    rezaaprian

    Joined:
    Jul 20, 2017
    Posts:
    2
    Great script, currently having fun with it..

    So I made a swimming animation and put it on the Diving state on rectangle animator controller. But then I realize when on water the engine play the jump&fall animation instead. I though the Diving parameter is for when we are on water.. but not? (is it an ability like Crash Bandicoot dive instead?). How if I want to use my swimming animation when we are on water?

    Still not much experience on Unity, I would really grateful for proper direction
     
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @rezaaprian > Please use the support email for requests like that, thanks. There's no swimming animation on the example characters, you'll have to implement it (there are tons of examples of how to trigger animations throughout the engine). Diving is not for swimming, it's an action you can trigger with jump and then down + dash.
     
  3. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Hopefully quick question: I've noticed that the WeaponLaserSight script has a little problem which I'm not sure how to solve. There are two public Vector3's which control the raycast and laser origin offset. Changing the X value works fine (you can move the origin of the raycast and linerender startpoint left or right) but any change to the y value does absolutely nothing. So if the desired origin isn't lined up on the y axis with the transform.position.y of the weapon itself, then the laser doesn't project correctly. Anyone found a solution for this?
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @NAiLz > There's a bug there indeed. I'll fix it for the next release. Thanks for reporting it!
    Please send me an email when you find one instead of posting here, that way I can keep track of issues and send the fix to the people who found the bug. Too messy for me otherwise.
    I'll have that one fixed soon so if you want the fix before the next release drop me a line.
     
  5. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    370
    Thanks reuno for the great update!
     
  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    You're welcome! I'm glad you like it!
     
  7. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88

    Just an update for anyone who is interested... here is a physical version of the surface modifier script I'm using to get movable objects (pushable blocks etc) to move along with surface modifier objects. All you need to do if you want friction is to create a PhysicsMaterial2D with the desired friction and then add that to the Collider2D of the surface you want to create friction for your movable object. It's simple, there might be a cleaner solution and I thought about extending rather than having a separate script but *shrug*.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.CorgiEngine;
    5. using MoreMountains.Tools;
    6.  
    7. public class SurfaceModifierPhysics : MonoBehaviour {
    8.  
    9.     [Header("Force")]
    10.     [Information("Use these to add X or Y (or both) forces to any CorgiController that gets grounded on this surface. Adding a X force will create a treadmill (negative value > treadmill to the left, positive value > treadmill to the right). A positive y value will create a trampoline, a bouncy surface, or a jumper for example.",MoreMountains.Tools.InformationAttribute.InformationType.Info,false)]
    11.     /// the amount of force to add to a CorgiController walking over this surface
    12.     public Vector2 AddedForce=Vector2.zero;
    13.     /// bool which lets the fixedUpdate method know to move the object
    14.     private bool movableObjectInMotion;
    15.     /// gets the rigidbody of the object which enters the trigger
    16.     private Rigidbody2D rb;
    17.  
    18.     /// <summary>
    19.     /// Raises the trigger enter2 d event.
    20.     /// </summary>
    21.     /// <param name="collider">Collider.</param>
    22.     public virtual void OnTriggerEnter2D(Collider2D collider)
    23.     {
    24.         if(collider.tag == "MovableObject")
    25.         {
    26.             rb = collider.GetComponent<Rigidbody2D>();
    27.             movableObjectInMotion = true;
    28.         }
    29.     }
    30.  
    31.     /// <summary>
    32.     /// Raises the trigger exit2 d event.
    33.     /// </summary>
    34.     /// <param name="collider">Collider.</param>
    35.     public virtual void OnTriggerExit2D(Collider2D collider)
    36.     {
    37.         if(collider.tag == "MovableObject")
    38.         {
    39.             movableObjectInMotion = false;
    40.         }
    41.     }
    42.  
    43.     /// <summary>
    44.     /// Called after update for physics objects
    45.     /// </summary>
    46.     void FixedUpdate ()
    47.     {
    48.         if(movableObjectInMotion)
    49.         {
    50.             rb.AddForce((transform.right * AddedForce.x) * 22.75f);
    51.             rb.AddForce((transform.up * (Mathf.Sqrt( 2f * AddedForce.y * -5 ))) * 22.75f);
    52.         }
    53.     }
    54. }
     
    reuno likes this.
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @vudong > Have you tried using the search?
    If they don't appear, I'd suggest reading the FAQ, you probably don't have the required version.
     
  9. statrick

    statrick

    Joined:
    Oct 12, 2013
    Posts:
    4
    Hello Reuno

    Just purchaced corgi. I just started learning Unity and corgi is a great resource for me to learn from. I've been looking through these comments for a solution to what is probably a simple problem i'm having. If someone has already figured it out can you point me to the solution? I'm trying to play a landing animation on HitTheGround but I can't seem to get the HitTheGround parameter to trigger a state. Is there a better solution for accomplishing a landing animation?
     
    weberdls likes this.
  10. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @statrick > Well there are certainly other ways, there always are, but using the already built-in HitTheGround parameter should work just fine. Otherwise you can go deeper and bind the controller's State.JustGotGrounded, but it's more or less the same thing, and I'd say it'd duplicate functionality, which usually isn't a good idea.

    To set it up the built-in way, it's pretty straightforward, and doesn't require any coding, you just have to add an animator parameter called "HitTheGround" to your animator (if there isn't already one), and then bind whatever transition you want to the fact that this parameter is true. It's a bool, and will be true on the frame you touch the ground, as the name implies :)
     
  11. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    Has anyone successfully interfaced Rewired to Corgi ?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I have an integration that is 95% finished but I haven't released yet. Let me know if you want a preview version to use.
     
    rrahim, Evil-Otaku and reuno like this.
  13. Unity_Freak

    Unity_Freak

    Joined:
    Jul 18, 2017
    Posts:
    6
    hello everyone
    i have question, how to make player selector on this asset i have try to do that by myself but i could not make it, does anybody know how to do that?
     
  14. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @Unity_Freak > It's on the todo list, and quite high as it's been requested multiple times already, but in the meantime you can implement it yourself if you want, it's not too hard, all you have to do is let the LevelManager know what character you want to use, from your level selection scene. It's exactly the same process as what's already in place, but right now you set that up via the inspector.
     
    NAiLz likes this.
  15. Unity_Freak

    Unity_Freak

    Joined:
    Jul 18, 2017
    Posts:
    6
    thanks i'll try that, i hope this feature include in the next release
     
  16. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @Unity_Freak > If it's not in the next release it'll be in the one after that, still figuring out priorities at the moment :)
     
    NAiLz and rrahim like this.
  17. karmik

    karmik

    Joined:
    Oct 8, 2014
    Posts:
    124
    Hi Guys. May be way off topic.
    I bought this for one of the game I am developing currently. But I have plants vs zombies also in mind for future.
    So wanted to check how easy or difficult is it to develop a game like plants vs zombies with it
    Any one tried?

    An example from author or pointers in the directions would be great
    May an example would add more value to the asset
     
    Last edited: Jul 28, 2017
  18. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @karmik > I don't see many common points between Plants vs Zombies and a platformer, so...
    As for how easy or difficult, it depends on your own skills, it's impossible to answer a question like that :)
     
  19. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    Oh YES PLEASE :)
     
    reuno likes this.
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Hi,

    I've actually released the Rewired update with the Corgi Engine integration. It's available on my website to download now for registered users. If you'd like to register to get early access to updates, please contact me here or PM me your email address. The update will be submitted to the Asset Store when the current pending submission is approved.
     
    NAiLz, Evil-Otaku and reuno like this.
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Agreed. Thanks for the Rewired integration @guavaman cannot wait to check it out.
     
  22. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Unity_Freak: I've been working on one. I'll be happy to share the code if you like. It's messy right now but it's a start in the general direction.
     
  23. durrab

    durrab

    Joined:
    Jul 7, 2013
    Posts:
    6
    HI,

    I have updated to the new corgi engine and now all the scenes which I run from IDE to Android, I found the issue in respawning.

    So whenever my player dies, It just falls down and when I did the debugging I got this message

    AndroidPlayer(ADB@127.0.0.1:34999)</i> IOException: Cannot create /data/app/fileName/com.durrab.FileName/base.apk because a file with the same name already exists.
    at System.IO.Directory.CreateDirectory (System.String path) [0x000a1] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:97
    at System.IO.DirectoryInfo.Create () [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/DirectoryInfo.cs:141
    at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00023] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:116
    at System.IO.Directory.CreateDirectory (System.String path) [0x0009a] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:96
    at System.IO.DirectoryInfo.Create () [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/DirectoryInfo.cs:141
    at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00023] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:116
    at System.IO.Directory.CreateDirectory (System.String path) [0x0009a] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:96
    at MoreMountains.Tools.SaveLoadManager.Save (System.Object saveObject, System.String fileName, System.String foldername) [0x0001c] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/SaveLoad/SaveLoadManager.cs:63
    at MoreMountains.Tools.MMAchievementManager.SaveAchievements () [0x0002c] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Achievements/Scripts/MMAchievementManager.cs:171
    at MoreMountains.Tools.MMAchievementRules.OnMMEvent (MMGameEvent gameEvent) [0x00024] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Achievements/Scripts/MMAchievementRules.cs:48
    at MoreMountains.CorgiEngine.AchievementRules.OnMMEvent (MMGameEvent gameEvent) [0x00003] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Achievements/AchievementRules.cs:27
    at MoreMountains.Tools.MMEventManager.TriggerEvent[MMGameEvent] (MMGameEvent newEvent) [0x00036] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Events/MMEventManager.cs:155
    at MoreMountains.Tools.MMAchievement.UnlockAchievement () [0x00023] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Achievements/Scripts/MMAchievement.cs:63
    at MoreMountains.Tools.MMAchievementManager.UnlockAchievement (System.String achievementID) [0x0001c] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Achievements/Scripts/MMAchievementManager.cs:59
    at MoreMountains.CorgiEngine.AchievementRules.OnMMEvent (CorgiEngineEvent corgiEngineEvent) [0x00030] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Achievements/AchievementRules.cs:52
    at MoreMountains.Tools.MMEventManager.TriggerEvent[CorgiEngineEvent] (CorgiEngineEvent newEvent) [0x00036] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/MMTools/Events/MMEventManager.cs:155
    at MoreMountains.CorgiEngine.LevelManager.KillPlayer (MoreMountains.CorgiEngine.Character player) [0x00027] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Managers/LevelManager.cs:349
    at MoreMountains.CorgiEngine.Health.Damage (Int32 damage, UnityEngine.GameObject instigator, Single flickerDuration, Single invincibilityDuration) [0x0014a] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Agents/Core/Health.cs:214
    at MoreMountains.CorgiEngine.DamageOnTouch.OnCollideWithDamageable (MoreMountains.CorgiEngine.Health health) [0x000fc] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:202
    at MoreMountains.CorgiEngine.DamageOnTouch.Colliding (UnityEngine.Collider2D collider) [0x0008b] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:165
    at MoreMountains.CorgiEngine.DamageOnTouch.OnTriggerEnter2D (UnityEngine.Collider2D collider) [0x00003] in /Users/djamikhan/Desktop/UnityProjects/Bamboo The Monster/Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:127

    (Filename: /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs Line: 97)
     
  24. durrab

    durrab

    Joined:
    Jul 7, 2013
    Posts:
    6
    I found the issue in MMAchievementRules and here is the code when we save the achievement and

    public virtual void OnMMEvent(MMGameEvent gameEvent)
    {
    switch (gameEvent.EventName)
    {
    case "Save":
    MMAchievementManager.SaveAchievements ();
    break;
    }
    }

    And here it creates an Exception on Android Device in SaveLoadManager.cs

    public static void Save(object saveObject, string fileName, string foldername = _defaultFolderName)
    {
    string savePath = DetermineSavePath(foldername);
    string saveFileName = DetermineSaveFileName(fileName);
    // if the directory doesn't already exist, we create it
    if (!Directory.Exists(savePath))
    {
    Directory.CreateDirectory(savePath);
    }
    // we serialize and write our object into a file on disk
    BinaryFormatter formatter = new BinaryFormatter();
    FileStream saveFile = File.Create(savePath+saveFileName);
    formatter.Serialize(saveFile, saveObject);
    saveFile.Close();
    }

    Whenever you save the Achievement then it is recreating the apk file so it throws an IOException - I will try to fix it.
     
  25. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    62
    hey reuno!
    now that you have the inventory working, your featuree lsit its almost complete!
    • castlevania like stairways
    • ledge hang/climb
    • key and chest
    • save & load
    • more weapons
    • and much more...
    can i suggest a couple? what about grapling hook and minimap (metroid style)? thanks!
     
  26. Unity_Freak

    Unity_Freak

    Joined:
    Jul 18, 2017
    Posts:
    6
    Yes please share your code with me, it would be nice to have that
     
    NAiLz likes this.
  27. durrab

    durrab

    Joined:
    Jul 7, 2013
    Posts:
    6
    HI,

    There is another issue - If I try to run Corgi Engine on Android from usb drive then jumps, fires, and other buttons except jet flying are not working. - Can I get the help please - I am using Unity 2017 f1
     
  28. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @durrab > Sorry for the late reply, for some reason I don't get notifications from the forum anymore. Regarding the achievements save, you may need to update the path it saves to depending on your specific device. I don't reproduce any of these errors when I build for Android, and they've not been reported either. I'd need more info to help. Please send me more details about your target device and engine version on the support email and I'll see what I can do, thanks.

    @xpachin > I'd need to update the todo list, it's much longer than that one :) Yours were already there by the way, but I've just moved them up a bit :)
     
    Bhanshee00 likes this.
  29. Luremaster

    Luremaster

    Joined:
    Dec 17, 2016
    Posts:
    9
    Thumbs Up for Minimap!!!! :D
     
    reuno likes this.
  30. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    62
    excelent!!!
     
  31. durrab

    durrab

    Joined:
    Jul 7, 2013
    Posts:
    6

    Do one thing - without doing any jumps directly goto the enemy and let this enemy to kill your player then you will see that your player is falling down and down and I see the IOException in the console by using debug script by connecting the Android Player.

    I have tested on the Following devices and same error.

    1. Galaxy S8+
    2. LG Tribute
    3. Samsung Tab 8

    Note: You should run it by connecting it using usb device as development build and select profiler as well as script debugging
     
    Last edited: Aug 1, 2017
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @durrab > As I said, I don't reproduce that error. Please use the support email address, I won't handle that kind of support request in the forum.
     
  33. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    Bit of a longshot, but worth a try : to the person who emailed me with a cool way to exclude properties in editors : thank you. Next time write your email in the email field though :)
     
  34. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    If you're having trouble with saves and Android (@durrab for example), you can try changing the "Application.dataPath" in SaveLoadManager.cs into "Application.persistentDataPath".
     
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    [Shameless unrelated self promotion] I took part in the Ludum Dare 39 gamejam this weekend, and created a game in less than 72 hours, from scratch. It's called PowerPlay, and it's about one guy standing against an army of robots in a rugby match. Of course it's made with Unity, and if people like it I may turn it into a proper ball sports asset, as I ended up implementing a lot of ball related stuff (passes, throws...) that didn't make it into the final cut. Making sports games is super fun, I hope I'll come back to that!

    Here's the trailer for it:


    You can get the game for free on itch.io, and there's a web version too (but really get the PC or Mac versions, they're better).
     
    Bhanshee00 and Bagnol like this.
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
  37. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Unity_Freak,
    Here it is. Like I said this is a bit sloppy so any improvements anyone thinks of would be welcome. I'm always a bit hesitant to post code since I'm not really a coder strictly speaking, I just know enough to get along in the projects I'm working on. ;) Anyway, hope it helps. The premise is that you attach this to a game object which acts as a switch, so it requires that the game object has a Collider2D (built into the script as you can see). The public game objects are explained in comments/headers but one is for the player character you wish to select, the helper icon pops up when a player enters the trigger (to prompt the player to press a button... mine has a button icon over it which later I'll code to use whichever icon the player has key-mapped for jump) and the ready icon is just an icon indicating that the player is ready. This is used when there are multiple players in the scene. My setup is a bunch of cryogenic freezers where the characters are suspended and you go around and select the one you want. That's why it's set up in a switch. You could easily modify this to work with any other interface if you look at the SelectCharacter and DeselectCharacter methods to see what I'm doing there.

    The CheckPlayerReady script is used to compare the number of players in the scene to the number of players who are in a "ready state" This is to ensure that all players on the screen have selected a character before the script loads the next screen. I plan to add a countdown and cancel option to it instead of instantly loading the next scene.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.CorgiEngine;
    5. using MoreMountains.Tools;
    6.  
    7. [RequireComponent(typeof(BoxCollider2D))]  //makes sure that any GameObject with this script attached has a BoxCollider2D
    8.  
    9. public class CharacterSelectSwitch : MonoBehaviour {
    10.  
    11.     [Header("Drag In The Character Prefab You Want This Switch To Load")]
    12.     public GameObject characterToLoad;  //prefab of the character this switch should load into the LevelManager script
    13.  
    14.     [Header("Drag In A Button Prompt Icon")]
    15.     public GameObject helperIcon;  //helper icon which prompts the player to action
    16.  
    17.     [Header("Drag 'Ready' Text/Icon Here")]
    18.     public GameObject readyIcon;  //icon which indicates that the player has selected this character for play
    19.  
    20.     private string playerID;  //used to store the PlayerID of the player using the switch
    21.  
    22.     private Character character;  //used to reference the Character script on the player using the switch
    23.  
    24.     private LevelManager levelManager;  //used to reference the LevelManager script in this scene
    25.  
    26.     private CharacterJump jumpScript;  //used to reference the CharacterJump script on the player using this switch
    27.  
    28.     private CheckPlayerReady checkPlayerReady;  //reference to the CheckPlayerReady script, used to load the next level when all players have selected a character
    29.  
    30.     public bool triggerEnabled;  //bool keeping track of whether or not the trigger can be used by the player
    31.  
    32.     private bool isTriggered;  //bool keeping track of whether or not the player has activated the switch
    33.  
    34.     private GameObject playerInTrigger;  //stores the current player using the trigger, used to ignore other players in OnTriggerEnter2D and OnTriggerExit2D
    35.  
    36.  
    37.     void Awake ()
    38.     {
    39.         levelManager = FindObjectOfType<LevelManager>();  //finds and references the LevelManager script in the scene
    40.         checkPlayerReady = FindObjectOfType<CheckPlayerReady>();  //finds and references the CheckPlayerReady script in the scene
    41.         triggerEnabled = false;  //tells Update that the trigger can be used
    42.         isTriggered = false;  //tells Update that the switch has been triggered
    43.     }
    44.  
    45.     void OnTriggerEnter2D (Collider2D col)
    46.     {
    47.         if(col.tag == "Player" && !triggerEnabled && playerInTrigger == null)  //checks tag of the collider, triggerEnabled bool status and whether there is a player already in the trigger
    48.         {
    49.             playerInTrigger = col.gameObject;  //stores the current using player's GameObject into the playerInTrigger variable for comparisson later
    50.             character = col.GetComponent<Character>();  //references the Character script in the current using player
    51.             jumpScript = col.GetComponent<CharacterJump>();  //references the CharacterJump script in the current using player
    52.             helperIcon.SetActive(true);  //activates the action prompt icon
    53.             jumpScript.enabled = false;  //disables player jump
    54.             triggerEnabled = true;  //tells Update that the trigger can be used
    55.             playerID = character.PlayerID;  //captures the PlayerID from the current using player for use later
    56.         }
    57.         else
    58.         {
    59.             return;
    60.         }
    61.     }
    62.  
    63.     void OnTriggerExit2D (Collider2D col)
    64.     {
    65.         if(col.tag == "Player" && triggerEnabled && col.gameObject == playerInTrigger)  //checks tag of the collider, triggerEnabled bool status and whether the player exiting the trigger is the one already in the trigger
    66.         {
    67.             playerInTrigger = null;  //nullifies the stored user player's GameObject
    68.             helperIcon.SetActive(false);  //turns off the action prompt icon
    69.             jumpScript.enabled = true;  //enables the player jump
    70.             triggerEnabled = false;  //tells update that the player can no longer use this trigger
    71.             character = null;  //nullifies the referenced Character script
    72.             playerID = null;  //nullfies the referenced PlayerID string
    73.         }
    74.         else
    75.         {
    76.             return;
    77.         }
    78.     }
    79.  
    80.     void Update ()
    81.     {
    82.         if(triggerEnabled)  //checks this bool status
    83.         {
    84.             if(Input.GetButtonDown(playerID + "_Jump"))  //checks for input from the current user player
    85.             {
    86.                 if(!isTriggered)  //checks this bool status
    87.                 {
    88.                     isTriggered = true;  //lets update know the player has activated the switch
    89.                     character.Freeze();  //freezes character movement
    90.                     SelectCharacter();  //calls the SelectCharacter method
    91.                     readyIcon.SetActive(true);  //activates the player ready icon
    92.                 }
    93.                 else
    94.                 {
    95.                     isTriggered = false;  //lets update know the player has deactivated the switch
    96.                     character.UnFreeze();  //unfreezes character movement
    97.                     DeselectCharacter();  //calls the DeselectCharacter method
    98.                     readyIcon.SetActive(false);  //deactivates the player ready icon
    99.                 }
    100.             }
    101.         }
    102.     }
    103.  
    104.     /// <summary>
    105.     /// This method looks for the PlayerID of the current user player and then based on which one is using the switch,
    106.     /// assignes the selected switch's character to that player
    107.     /// </summary>
    108.     void SelectCharacter ()
    109.     {
    110.         if(playerID == "Player1")
    111.         {
    112.             levelManager.PlayerPrefabs[0] = characterToLoad.GetComponent<Character>();
    113.             checkPlayerReady.playersReady += 1;
    114.         }
    115.         if(playerID == "Player2")
    116.         {
    117.             levelManager.PlayerPrefabs[1] = characterToLoad.GetComponent<Character>();
    118.             checkPlayerReady.playersReady += 1;
    119.         }
    120.         if(playerID == "Player3")
    121.         {
    122.             levelManager.PlayerPrefabs[2] = characterToLoad.GetComponent<Character>();
    123.             checkPlayerReady.playersReady += 1;
    124.         }
    125.         if(playerID == "Player4")
    126.         {
    127.             levelManager.PlayerPrefabs[3] = characterToLoad.GetComponent<Character>();
    128.             checkPlayerReady.playersReady += 1;
    129.         }
    130.     }
    131.  
    132.     /// <summary>
    133.     /// This method looks for the PlayerID of the current user player and then based on which one is using the switch,
    134.     /// nullifies the selected switch's character
    135.     /// </summary>
    136.     void DeselectCharacter ()
    137.     {
    138.         if(playerID == "Player1")
    139.         {
    140.             levelManager.PlayerPrefabs[0] = null;
    141.         }
    142.         if(playerID == "Player2")
    143.         {
    144.             levelManager.PlayerPrefabs[1] = null;
    145.         }
    146.         if(playerID == "Player3")
    147.         {
    148.             levelManager.PlayerPrefabs[2] = null;
    149.         }
    150.         if(playerID == "Player4")
    151.         {
    152.             levelManager.PlayerPrefabs[3] = null;
    153.         }
    154.     }
    155. }
    156.  
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.CorgiEngine;
    5. using MoreMountains.Tools;
    6.  
    7. public class CheckPlayerReady : MonoBehaviour {
    8.  
    9.     public int numberOfPlayers;  //keeps track of the number of players who are in the current scene and also expands the PlayerPrefabs array based on this number
    10.     public int playersReady;  //keeps track of the number of players who have selected a character and indicated that they are ready
    11.  
    12.     private LevelManager levelManager;
    13.     private PlayerSelectionInputListener playerSelectionInpuListener;
    14.  
    15.     void Awake ()
    16.     {
    17.         levelManager = FindObjectOfType<LevelManager>();
    18.         playerSelectionInpuListener = FindObjectOfType<PlayerSelectionInputListener>();
    19.     }
    20.  
    21.     void Update ()
    22.     {
    23.         if(playersReady >= numberOfPlayers && playersReady != 0)  //if the number of players who are ready match the number of players in the scene, it executes its actions
    24.         {
    25.             LoadGame();  //Calls the LoadGame method
    26.         }  
    27.     }
    28.  
    29.     /// <summary>
    30.     /// This method loads the next level when all players are ready
    31.     /// </summary>
    32.     void LoadGame ()
    33.     {
    34.         //Debug.Log("All Players Ready!  Load The Next Level!");
    35.         levelManager.GotoLevel("__Testing");
    36.         playerSelectionInpuListener.enabled = false;
    37.         this.enabled = false;
    38.     }
    39. }
     
    Unity_Freak and reuno like this.
  38. Unity_Freak

    Unity_Freak

    Joined:
    Jul 18, 2017
    Posts:
    6
    thanks a lot, its very useful for me
     
  39. joshua121

    joshua121

    Joined:
    Jan 31, 2015
    Posts:
    7
    Has anyone successfully implemented having melee and projectile weapons equipped at the same time? And if so, how did you do it? I'm a little lost as to how to accomplish this. Thanks in advance.
     
  40. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @joshua121 > Sure, you can either duplicate the CharacterHandleWeapon ability into a CharacterHandleSecondaryWeapon (for example )ability, or switch between both weapons based on input.
     
    NAiLz likes this.
  41. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    When I was working on dual wielding and special attacks reuno gave me the advice to duplicate/extend as he mentioned above and it worked really well. I wonder what your goal is though. Do you want them to both fire at the same time or to be able to fire them separately depending on the button pressed. If that's the case, I'd still go with a duplicate "CharacterHandleSecondaryWeapon" script and then just change the input.
     
    reuno likes this.
  42. admin_2SGamix

    admin_2SGamix

    Joined:
    Apr 27, 2013
    Posts:
    12
    @reuno I am buying it right now. Working on beat 'em up 2D platformer.
    Some questions :
    1. I want to do dash characters on slopes made with polygon colliders.
    2. Slopes on straight road should shave collision from front but none from back and at the same time character should be colliding with the straight road.
    3. I hope I can customize it for Punch, Kick and Some combos (Most important).
     
    NAiLz likes this.
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
  44. o0neza0o

    o0neza0o

    Joined:
    Sep 6, 2015
    Posts:
    165
    Hey, love the corgi pack :) absolutely awesome :D. Just working on a project and well trying to figure out how to make an upgrade system or shop in the menus so that players can purchase weapon upgrades and also thinking about doing multiplayer too where players can do tdm or free for all or something similar XD just ideas atm but how would i go about doing this and with multiplayer, would corgi be okay to setup with photon?
     
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @o0neza0o > Not sure if this is a question :) But I can't really explain how to setup a shop or multiplayer in a forum post, these are large features that can't really be summed up like that :) As for photon, yes, I guess the engine won't get in your way. That said, if you even ask the question, I'm guessing you're pretty new at this, and be aware that online multiplayer is (in my opinion) one of the hardest task to tackle in Unity, so maybe start with something smaller.
    Good luck with your project!
     
  46. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    Helo reuno,

    I havent seen any info about it (probably missed it somewhere) but, is it possible to use the touch controller to drag and drop the character and have, say a left right conrtroller at the same time?

    Thank you
     
  47. ancamseg

    ancamseg

    Joined:
    Aug 6, 2017
    Posts:
    3
    Hi @reuno. I hope you are fine.

    I have an issue with Corgi 4.0. If I import the package into Unity and then build a single scene for Android. Mesa1 for example. When the player dies in the phone it does not revive but when it dies in computer it revives. Any idea why? Am I doing something wrong? (It is happening the same with my own game)
     
  48. fbarboza

    fbarboza

    Joined:
    Jun 5, 2017
    Posts:
    8
    Greetings,

    Anyone has some tip of how can I get the player that casted the Projectile using the MMDamageTakenEvent?
    I alreay got the Projectile using:
    (Projectile)eventType.Instigator.gameObject.GetComponent<Projectile>();
    But I can't reach the Player that casted the projectile.

    Thanks,

    Fabio
     
  49. ancamseg

    ancamseg

    Joined:
    Aug 6, 2017
    Posts:
    3
    This is what happens in the phone when player dies.
     

    Attached Files:

  50. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,926
    @Sofiel > You didn't miss it. It's certainly possible but it's not built-in. It's quite uncommon and has never been requested, but I'm sure you can implement it. I'd start with extending the InputManager to handle something like that.

    @ancamseg > As mentioned a few posts above yours : "If you're having trouble with saves and Android, you can try changing the "Application.dataPath" in SaveLoadManager.cs into "Application.persistentDataPath"." I'm pretty sure that's what the error you get tells you.

    @fbarboza > I'm on holidays right now and don't have access to the source files (3G and github don't mix apparently), so I can't check for sure, but I believe it's not possible right now. That said it'd be pretty easy to do. Projectiles have a protected _owner attribute, which is what you're after. You'd just need to make it public or expose it (better) and then you could access the player that shot the projectile using something like event.Instigator.gameObject.GetComponent<Projectile>().Owner. That'd return the player gameobject that shot the projectile.