Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    370
    Hello reuno... it's me again :(

    Not sure if this was asked before, but is there a way to integrate Corgi & Super Tilemap Editor by Creative Spore?

    During some discussions... I want to create some tiles that are like "tar pits". Meaning that when the player is on them, the player will be slowed. One way to code this is to make it so the Player controller (corgi) constantly checks on what tile it is, and when it finds that it's on a tile that "has some properties" ... do an event or something, on my case, run the "slow function".

    Also, you know that I was using FlowCanvas to access some of Corgi's variables. I couldn't access some of the variables because they were "fields" and FlowCanvas didn't supported to read/write "fields"... whatever they are. Well, now they are supported :)

    So I was able to access the "Numer of Jumps" variable and ... change it :D Now I can have a "Double Jump" buff.


    Thanks <3
     
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @xpachin > If it's any consolation, I moved the minimap up a bit. Hopefully with the (soonish) release of Unity's tilemap system it'll come sooner than expected :)
    @GamerPET > I don't know Super Tilemap Editor but if they work with Unity's native box colliders I don't see why not.
    As for tar pits, your solution would technically work, but it'd be much quicker to use override zones for that. The CharacterHorizontalMovementOverride component for example would do the trick. It allows you to alter ability properties while the character is in the zone (a boxcollider2D).
    I'm glad "fields" are supported now, I still don't know what they are for Flowcanvas, but that's good news nonetheless!
     
    GamerPET likes this.
  3. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    62
    mmm. don't know if that's good or bad. i use ferr2d for terrains, so I don't know if it will be tilemap dependant or what...
    anyway, any new about grappling hook?
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @xpachin > How do you expect the minimap to work automatically with Ferr2D? What features do you expect there? Just the position inside the scene? Or the actual "mini" platforms?
    As for the grappling hook, it's still on the todo list (no need to ask for all features, there's a reason why I don't give ETAs).
     
  5. DTGameDev

    DTGameDev

    Joined:
    Nov 20, 2016
    Posts:
    2
    how can i fix this problem
     

    Attached Files:

  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @DTgame > A bit hard to answer that without any context, isn't it?
    I'd say reset and empty your inventories, for a start. If the problem persists, please send me more info (Unity / engine version, context...) on the support email address, not here, thanks.
     
  7. DTGameDev

    DTGameDev

    Joined:
    Nov 20, 2016
    Posts:
    2
    more mountains/reset all saved inventories

    this way worked
     
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
  9. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    About the minimap feature.
    There's two ways a map could fit onto a 2D platform game: A map you can look on a pause menu option or a GPS like minimap on a corner of the screen. Either choice, I'm trying to remind games with this feature and not much comes to my mind so maybe this is not a generic feature at all.
    However, it can be nice because, in combination with inventory, key-door system and other stuff from 4.2 it opens the way to create neat games focused on adventure more than platforming.

    This is just my opinion, take it with a pinch of salt.
     
    reuno likes this.
  10. Luremaster

    Luremaster

    Joined:
    Dec 17, 2016
    Posts:
    9
    The minimap on menu its a must have for any metroidvania, i think almost all those games got a minimap. About the GPS one its really very rare.
     
    Zehru and reuno like this.
  11. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    62
    i don't know, and i don't want to work with ferr2d, it has to be generic to work with any tool.. maybe, it could take the terrain coliders of a certain layer to automatic generate a basic "shape" of the scene, with another camera. plus the items could have an option to appear in the minimap as an icon. just ideas, i don't know if its possible. the other way is to have a tool or editor to pre-draw the shapes for the minimaps, an put the icons. i do'nt know :p
     
    Last edited: Oct 11, 2017
    reuno likes this.
  12. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    62
    yeah that's right. it is a "must have" for school games. and the minimap (wich i understand has te one on gamescreen like you "gps") does'nt have to have the entire detail of the scene, it's more like a guide to know where are you, and to know if there is an item or door around there. the pause map is another thing, and it should be get more complete as you enter new areas or find a "Map" (metroid) or "compass" (zelda). (the diference is the map only give you the shapes and doors and the compass show items and bosses)
     
    reuno likes this.
  13. TinkersEdge

    TinkersEdge

    Joined:
    Oct 4, 2016
    Posts:
    6
    Has anyone figured a simple way to make the text in the dialogue boxes dynamic? Or take input? or have options? I am attempting to make a spot where the player has to answer a question before they can enter a door. So, they would answer the question, the NPC would give them a key and then they could go through. I have an array filled with the questions and answers, but I cannot seem to figure how to make the the dialogue box pull the question from the array an place it in the dialogue box. Once I figure that, I should be able to adjust the dialogue box with the answers or make it fill in the blank I think.

    I see that the DialogueZone creates a string Array called Dialogue, but can't quite figure out where that is processed. A point in the right direction would be great! Thanks!
     
  14. LittleBlueHat

    LittleBlueHat

    Joined:
    Dec 6, 2014
    Posts:
    16
    Hey everyone,

    Hope you are all enjoying 4.2. I wanted to share another extension I have made, this time it is for Character Ladder. I wanted to use ladders like hanging ropes where you could jump from one to the next. In using the ladders this way I needed to add two things. I needed to reset my jump counter after I attached to a ladder and I wanted to be able to use the run speed.

    By default, if you attach to a ladder and have already used 2/2 jumps, you only get one more off of the ladder. When you reset them, it allows your player to be a little more acrobatic!

    The second thing was the accessing the run speed. By default, if you are using your holding down the Run button, jump to a ladder and keep the Run Button held down the entire time you are on the ladder, when you jump off your character retains that run speed for it's mid-air movement. If you release the Run Button at any time while on the ladder and jump off, your character speed reverts to its normal walk speed even if you press the Run Button again before you jump. For how I wanted to use the ladders this posed a problem as I needed enough speed to jump from ladder to ladder. I was able to extend the Character Ladder script to recognize the input while on the ladder. So if you pressed the Run Button and jumped off the ladder, your character will utilize the run speed (even in mid air). If you don't press the Run Button and jump off, the character will jump off the ladder with the regular walk speed.

    As always if anyone thinks they can use this, please let me know!

    Here is a video example:
     
    Muppo likes this.
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @TinkersEdge > It doesn't "create" an array, it's set via the inspector. It's the only input it takes right now. Have you tried searching for where that array is used? It's used in the PlayNextDialogue coroutine. Don't hesitate to ctrl+F for it next time, it'll be faster :) Or check out the code comments, it's all explained.

    @LittleBlueHat > That's really cool, thanks for sharing.

    I've been getting more and more contributions like these lately, I think it's time I open a public repo on github to regroup them all. I was thinking something simple, one folder per extension, with an explicit name, and commented code explaining at least how to use the extension and what it's for, and how you want to be credited. Something I can copy/paste and put on the repo's readme.

    So @LittleBlueHat, if you're interested, don't hesitate to drop me an email with your extensions attached. Or if you're used to github we can do pull requests if you prefer. @WarpZone if you're up for it I'd be happy to put your Flinching ability there too (and your other stuff too of course). Same goes for everyone, so feel free to let me know if you want to contribute.

    Once that repo contains a few contributions I'll share it with everyone and put a link to it on the asset's mini website.
     
    Shilo, Zehru, twomack37 and 4 others like this.
  16. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    With Unity's TileMap editor released, is there anything to look out for when creating a new game project?
    We currently didn't, but want to start soon using Corgi Engine. :)
     
  17. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @MardukCorp > I plan on making a dedicated update, that'll specifically show how you can do cool stuff mixing both.
    But there's nothing special, as long as you set your colliders properly, it should work out of the box.
     
  18. karmik

    karmik

    Joined:
    Oct 8, 2014
    Posts:
    124
    Hi Guys i finally got my game play setup after an all nighter. I love the wealth of options available with corgi

    Can some one please guide me how to end level after all enemies in level are dead. My player character is static and does not move. he only shoots.

    Please suggest me if there is an easier and inbuilt way to achieve it with corgi.
     
  19. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @karmik > That's an unusual use of the engine :) I'd be happy to check out your game when it's done.
    So there's no built in way to do that right now (it's quite specific), but it shouldn't be too hard to do. I guess the way I'd do it is create a new manager, that lives in the scene, on start looks for all the enemies in the scene (findObjectsByType or something), and then periodically checks how many are left. Or you could hook each death to a counter. Anyway when there's none left, you load the next scene.
     
  20. wekster

    wekster

    Joined:
    Apr 25, 2014
    Posts:
    5
    Hi,
    I have a character with a guitar as a weapon and he is shooting different projectiles (6 guitar strings, 6 different bullets). I'm stuck because I don't know how to pull off one thing. I need my weapon to play different audio clips on random each time I press the shoot button. Any idea how to pull that off? Ideal thing would be separate script with audio array because I wouldn't like to change corgi scripts because of the future updates.

     
    Zehru, karmik and Muppo like this.
  21. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @wekster > I'd recommend extending the ProjectileWeapon script for that, and overriding the WeaponStart method to add your random sound play. Should be pretty easy. And that way when the next update comes you won't lose anything.
    Edit : forgot to mention your light effects are very nice :)
     
    twomack37 and wekster like this.
  22. skayster

    skayster

    Joined:
    Aug 12, 2017
    Posts:
    46
    Loving your little guitar buddy! :)
     
    wekster likes this.
  23. wekster

    wekster

    Joined:
    Apr 25, 2014
    Posts:
    5
    @reuno Thanks for a quick reply. Unfortunately my coding skills are so low and your codes are something that terrifies me how complex it looks :) So if i got it correctly i should duplicate ProjectileWeapon script and somehow override SfxPlayWeaponStartSound() part from your Weapon.cs script?
     
  24. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @wekster > Extending is not as hard as it looks.
    In the doc (http://corgi-engine-docs.moremountains.com/creating-your-own-game.html#inheritance) I point at a few pages in the Unity documentation that should make things more obvious. There are also a lot of examples of that inside the engine. For example the ProjectileWeapon class extends Weapon, etc.

    Basically what you need to do is not duplicate ProjectileWeapon, but create a new class (GuitarWeapon maybe?) that inherits from / extends ProjectileWeapon. Inside, you just need to override the WeaponStart (I guess) method, call something like base.WeaponStart() inside it, and then add your own specific code. I may have simplified it a bit, but that's the basic idea. It can be tricky at first if code isn't your thing, but once you've mastered that, code really becomes very fun, because you don't have to reinvent the wheel and can just add your own twists to existing stuff.
     
    wekster likes this.
  25. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @karmik
    Have a project on the make right know with that behaviour, when all the enemies on a level are dead, a "next level" prompt appears and next level is loaded.
    It's done with default Unity 3D environment but I think it can fit what you need, just let me check if it can work on CorgiEngine as well (AKA if I can make it fit)

    @wekster
    I like your guitar-shooter too, looks neat.
    Hope you can figure out how to add these random FX.
     
    karmik and wekster like this.
  26. karmik

    karmik

    Joined:
    Oct 8, 2014
    Posts:
    124
    Thanks for the suggestions guys. I will try and come back if need more help :)
     
  27. LittleBlueHat

    LittleBlueHat

    Joined:
    Dec 6, 2014
    Posts:
    16
    @wekster Man guitar dude looks amazing lol

    If you are having a hard time extending the projectile I would be happy to see if I can do it for you. I am always looking for a challenge to help improve my scripting ability!

    I will only do it on one condition though. You must add a special shot where guitar dude does a windmill Pete Townsend strum and plays an entire chord not just one note. ;)

    Shoot me a message if you want.
     
    wekster and reuno like this.
  28. wekster

    wekster

    Joined:
    Apr 25, 2014
    Posts:
    5
    @LittleBlueHat
    Lol, cool :) Any help would be appreciated :)

    and check this out :)


    @reuno Thanks for those suggestions, I haven't be able to do it yet but at least I've learned something good last night.
     
    LittleBlueHat and reuno like this.
  29. LittleBlueHat

    LittleBlueHat

    Joined:
    Dec 6, 2014
    Posts:
    16
    @wekster haha! That is great. I will see if I can come up with a solution for you hopefully in the next few days as I will be a little busy this weekend.

    I also wanted to share another extension I made. This extension allows you to set a distance limit on your AI walk patrol. Now the AI will patrol within a set limit if you choose to have it activated. See below:

     
    Shilo, Muppo, wekster and 1 other person like this.
  30. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    It seems like a good time to introduce you all with the public contributions Corgi Engine repository:
    https://github.com/reunono/CorgiEngineExtensions

    Right now there's only a few extensions there, but hopefully it'll grow bigger over time.
    Again, it's free for everyone to use, I won't provide support for it (I'm not the author), and all contributions are welcome!
    I hope you'll like this!
     
    Shilo, twomack37, Muppo and 1 other person like this.
  31. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    I'm trying to make a multiplayer game (offline) and I need to get a list of all players in the level. This is what I've tried so far:
    List<Character> _players = MultiplayerLevelManager.Instance.Players;
    foreach (Character c in _players)
    {
    Debug.Log(c.PlayerID);
    }

    The problem is, for every iteration of the loop, it returns the same PlayerId: "Player1". I looked at the scene, and all the characters are spawned correctly, with their own unique PlayerID (Player1, Player2 etc).

    So my question is, what am I doing wrong? Why does my code return the same PlayerID for every player?
     
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @mightyboat > Not sure what you're doing wrong. I just gave it a try just to be sure, opened the Minimal4Players demo, added an empty gameobject, added a new class to it, and pasted your code in Update :
    upload_2017-10-14_18-15-40.png

    Looks fine to me.
     
  33. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    Thanks for that. This is very strange though. I tried doing what you did, opened the example scene, created a new gameobject and class containing the code, and the issue is still there.

    The loop iterates four times, which tells me the players are there, but the code still returns Player1 for all of them.
     
  34. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    You're running that code at Update and it outputs Player1 four times?
     
  35. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    Yep. It's really weird. Here's a screenshot showing Unity and the code. The console shows the same character for every player (Rectangle) which is fine, but the ID is the same:
    upload_2017-10-14_19-22-36.png

    Here's a screenshot showing all the player instances in the scene and the fact that the players have different IDs:
    upload_2017-10-14_19-27-14.png

    As you can see each player in the scene has a unique ID. Yet in the console, it shows the same ID... I don't get it!
     
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @mightyboat > Please try with a fresh install of the asset. You've probably changed something.
    If the problem persits, send me an email on the support email address with more details (version number, etc).

    That code in the screenshots is not gonna work. Not sure why you changed it since your initial message.
     
  37. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    @reuno Ok it seems to work now. I updated to the latest version just to be safe, and changed the code back to what it was (for some reason the code I posted earlier didn't work, which is why i changed it so how it is in the screenshot).
    Anyway thanks a lot for the fast response. It's working now.
     
    reuno likes this.
  38. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    @karmik
    Goods news, have a solution for you. It worked.
    It's a modified version onf the FinishLevel from the engine so if @reuno don't mind me to share that, I'll paste it here.
     
    karmik and LittleBlueHat like this.
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    karmik likes this.
  40. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Thanks @reuno

    Here it is:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. namespace MoreMountains.CorgiEngine
    5. {  
    6.     /// <summary>
    7.     /// Add this class to an empty object an the level will finish when required score is reached
    8.     /// </summary>
    9.     [AddComponentMenu("Corgi Engine/Spawn/AutoFinish Level")]
    10.     public class AutoFinishLevel : MonoBehaviour
    11.     {
    12.         public int ScoreRequired = 10;
    13.         public string LevelName;
    14.  
    15.         protected int CheckScorePoints;
    16.  
    17.         void Update ()
    18.         {
    19.             CheckScorePoints = GameManager.Instance.Points;
    20.  
    21.             if (CheckScorePoints >= ScoreRequired)
    22.             {
    23.                 GoToNextLevel();
    24.             }
    25.         }
    26.  
    27.         /// <summary>
    28.         /// Loads the next level
    29.         /// </summary>
    30.         public virtual void GoToNextLevel()
    31.         {
    32.             if (LevelManager.Instance!=null)
    33.             {
    34.                 LevelManager.Instance.GotoLevel(LevelName);
    35.             }
    36.             else
    37.             {
    38.                 LoadingSceneManager.LoadScene(LevelName);
    39.             }
    40.         }
    41.     }
    42. }
    Set the enemies total score points on the ScoreRequired via inspector and here you go. Keep in mind that if you have coins or other items wich adds to score it will count aswell because this does not check the game object kind.

    However this can be done without score points, but you need to modify Health script as well in order to add on a hidden counter instead score when the enemy dies.
     
    karmik likes this.
  41. karmik

    karmik

    Joined:
    Oct 8, 2014
    Posts:
    124
    @Muppo awsome. works like a charm.

    Guys Now i have another issue. I want the player projectile to be able to destroy enemy projectiles it hits. It does not seem to be working as guess it has some thing to do with both the projectiles having is trigger in collider. But I think the trigger option is needed for projectiles to detect collision on player / enemy which ever the projectile will hit.

    I tried adding another 2d collider which is not a trigger. But still does not seem to work. I also put projectiles in target layers mask. Please guide me how i can achive this. Maybe i am making a silly mistake somewhere.
     
  42. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Give the code another twist so it can now finish the level when score, amount of kills or both are fulfilled.
    Two scripts are needed in case you like kill count rather than score. Here they are.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MoreMountains.Tools;
    4.  
    5. namespace MoreMountains.CorgiEngine
    6. {  
    7.     /// <summary>
    8.     /// Based on FinishLevel script from Corgi Engine 4.2
    9.     ///
    10.     /// Add this class to an empty object an the level will finish when required condition is fulfilled
    11.     /// </summary>
    12.     [AddComponentMenu("Corgi Engine/Spawn/AutoFinish Level")]
    13.     public class AutoFinishLevel : MonoBehaviour
    14.     {
    15.         public enum BasedOn
    16.         { Score, Kills, Both }
    17.         public BasedOn BasedOnCondition;
    18.  
    19.         [Header("Level End Conditions")]
    20.         public int ScoreRequired = 100;
    21.         public int KillsRequired = 2;
    22.         [Information("Level will finish automatically when the selected condition is completed.\nIf just one is chosen, the other condition value will be ignored.",InformationAttribute.InformationType.Info,false)]
    23.         public string NextLevelName;
    24.  
    25.         protected int CheckScorePoints;
    26.         public static int KillsCount;
    27.  
    28.         public virtual void Update ()
    29.         {
    30.             if (BasedOnCondition == BasedOn.Score)
    31.             {
    32.                 CheckScorePoints = GameManager.Instance.Points;
    33.                 if (CheckScorePoints >= ScoreRequired)
    34.                 {    GoToNextLevel();    }
    35.             }
    36.  
    37.             if (BasedOnCondition == BasedOn.Kills)
    38.             {      
    39.                 if (KillsCount >= KillsRequired)
    40.                 {    GoToNextLevel();    }
    41.             }
    42.  
    43.             if (BasedOnCondition == BasedOn.Both)
    44.             {
    45.                 CheckScorePoints = GameManager.Instance.Points;
    46.                 if (CheckScorePoints >= ScoreRequired && KillsCount >= KillsRequired)
    47.                 {    GoToNextLevel();    }
    48.             }
    49.         }
    50.  
    51.         /// <summary>
    52.         /// Loads the next level
    53.         /// </summary>
    54.         public virtual void GoToNextLevel()
    55.         {
    56.             if (LevelManager.Instance!=null)
    57.             {
    58.                 LevelManager.Instance.GotoLevel(NextLevelName);
    59.             }
    60.             else
    61.             {
    62.                 LoadingSceneManager.LoadScene(NextLevelName);
    63.             }
    64.         }
    65.     }
    66. }
    And this one must be attached on any enemy you want to be counted when killed
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MoreMountains.Tools;
    4.  
    5. namespace MoreMountains.CorgiEngine
    6. {
    7.     [RequireComponent(typeof(Health))]
    8.     public class DeadCount : MonoBehaviour
    9.     {
    10.         /// <summary>
    11.         /// Add this script to an enemy AI with Health component and it will add one point to the kill count on Auto Finish Level script when die.
    12.         /// For use with Corgi Engine 4.2 +
    13.         /// </summary>
    14.         [HideInInspector]
    15.         protected Character _character;
    16.  
    17.         public virtual void Update ()
    18.         {
    19.             if (_character != null)
    20.             {
    21.                 if (_character.CharacterType == Character.CharacterTypes.AI)
    22.                 {
    23.                     AutoFinishLevel.KillsCount += 1;
    24.                 }
    25.             }
    26.         }
    27.     }
    28. }
    29.  
    As you can see, not the best nor clean code so feel free to enhance it if you like.
     
  43. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    @reuno I've tried to create a multiplayer level based on the Level Selection level (I need the movement functionality from that level).

    So, I created two InputManagers, set different player IDs, then added two characters (which are based on the Level Selection Corgi and the only difference is that it can change its sprite instead of changing levels), each with it's own player ID that matches an input manager.

    When I use the AWSD controls for character 1, character 2 also moves. I checked the inspector while playing, and the PlayerIDs are correctly assigned to each character and InputManager.

    Why do the two characters move? Is there some code I need to modify to make it work, or did I miss something in the setup?

    One difference between my scene, and the multiplayer scene is I didn't add a MultiplayerLevelManager. I looked at the code, and couldn't see anything that seemed important for my use case. Maybe I missed something?

    Thanks
     
  44. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @mightyboat > There's no support for multiplayer on the LevelSelection scene, but as far as I remember (can't check right now, on the move) input on that scene is much simpler than in the actual engine and doesn't rely on playerID. My advice would be to follow the string of events from input to character and see where to make the changes.
     
  45. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    Thanks for the pointers. If it doesn't rely on PlayerID that explains my issue. I'll keep digging.
     
  46. mightyboat

    mightyboat

    Joined:
    Apr 10, 2016
    Posts:
    14
    Just thought I'd follow up from my last post. I managed to get multiple level select based characters working. The level selection corgi uses the static InputManager.Instance for its control. So to get multiple players working, you need to assign a unique input manager for each. To do that, I added my characters and input managers to my scene, and modified the Start method of the character like so:

    Code (CSharp):
    1.  
    2.         InputManager BoundInputManager;
    3.  
    4.         protected virtual void Start ()
    5.  
    6.         {
    7.             // other code ....
    8.             // bind input manager
    9.             InputManager[] inputManagers = FindObjectsOfType<InputManager>();
    10.             foreach (InputManager im in inputManagers)
    11.             {
    12.                 if (PlayerID == im.PlayerID)
    13.                     BoundInputManager = im;
    14.             }
    15.         }
    And then replaced every instance of InputManager.Instance with BoundInputManager. Seems to work perfectly!
     
    reuno likes this.
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,872
    @mightyboat > Really good solution, thanks for sharing this!
     
  48. Muppo

    Muppo

    Joined:
    Sep 28, 2016
    Posts:
    242
    Ok, this is awkward.

    The second script I posted (DeadCount) does nothing. It was working for me because I added the code from the Update on the Health script (line 221)
    I'm sorry.

    It can work fine that way but I'm not happy with this so I'm trying to figure out how to make it works without modifing Health script.
     
  49. wekster

    wekster

    Joined:
    Apr 25, 2014
    Posts:
    5
    Now my guitar dude is finally playing random tones. If button is pressed more than 3 sec he starts playing guitar solo. If I release the button during that solo part music stops and a broken guitar string kicks in :D

    This cool thing wouldn't be possible without @LittleBlueHat who made this amazing guitar script.

     
    Kelgand, JamesArndt, Muppo and 4 others like this.
  50. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    EDIT:
    I modified the code to read as follows and it works. Leaving this here for anyone who might be interested now or in the future:
    Code (CSharp):
    1.     void Shoot()
    2.     {
    3.         //Reset the time when we shoot
    4.         shotTime = Time.time;
    5.  
    6.         GameObject obj = pooler.GetPooledObject();
    7.         projectilescript = obj.GetComponent<Projectile>();
    8.  
    9.         if(obj == null) return;
    10.  
    11.         obj.transform.position = muzzle.transform.position;
    12.         obj.transform.rotation = muzzle.transform.rotation;
    13.  
    14.         obj.SetActive(true);
    15.         projectilescript.SetDirection(muzzle.transform.right, muzzle.transform.rotation);
    16.     }





    Alright, so I've created a script to rotate an AI weapon to attempt to aim at the player and fire. This works fine but the problem I'm running into is that the projectile (I'm using the Corgi projectile script) just goes in a straight line to the right instead of following the path of the rotated object it spawns on. I'm not sure what's going on. Anyone have any possible solutions?

    Here's my Shoot method which is called when the player is within range and when a timer says the correct interval between shots has been met:
    Code (CSharp):
    1.     void Shoot()
    2.     {
    3.         //Reset the time when we shoot
    4.         shotTime = Time.time;
    5.  
    6.         GameObject obj = pooler.GetPooledObject();
    7.         projectilescript = obj.GetComponent<Projectile>();
    8.  
    9.         if(obj == null) return;
    10.  
    11.         obj.transform.position = muzzle.transform.position;
    12.         obj.transform.rotation = muzzle.transform.rotation;
    13.  
    14.         obj.SetActive(true);
    15.         projectilescript.SetDirection(muzzle.transform.position, muzzle.transform.rotation);
    16.     }

    It seems to rotate toward the player slowly if I give it a few shots to correct but I'm not sure why it doesn't inherit the muzzle rotation right away when it is activated from my pooler. :(
     
    Last edited: Oct 18, 2017