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. Dismiss Notice

Question How to Make a Round System of a Fighting Game Like Street Fighter or Mortal Kombat (C#)

Discussion in 'Scripting' started by TheFighterSFMK2022, Oct 12, 2022.

Thread Status:
Not open for further replies.
  1. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I almost made the round work

    I don't want to close this post of "How to Make a Round System of a Fighting Game Like Street Fighter or Mortal Kombat (C#)" if before I solve this first and I think I won't be able to sleep with this roundtracker
    I am now at "Junior Programmer: Create with Code 1"
     
    Last edited: Oct 18, 2022
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    What makes you think this? You haven't learned the basics of programming, so how do you know what is left to do?

    You're getting way ahead of yourself. Why not just go and learn the basics? If this is really something you want to do then that is the best way forward.
     
  3. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    If I have almost completed Unit 1 - Player Control, which was frustrating is the plane, before completing Lab 1 - Project Design Document I have to know the fighting game first, when I was in Lesson 1.3 - High Speed Chase, I joined it costs that the script the part of roundtracker
    Code (CSharp):
    1. var rt = RoundTracker.Instance;
    2.             if (rt.FinalRound())
    3.             {
    4.                 var winsTally = $"{CurrentWinsOf(RoundTracker.Side.Left)} to {CurrentWinsOf(RoundTracker.Side.Right)}";
    5.                 Debug.Log($"After {rt.TotalRounds} rounds, the winner of the " +
    6.                           $"match was the player on the {rt.FinalWinner:G}, " +
    7.                           $"with the score of {winsTally}.");
    8.             }
    if you have to be in BattleController,
    I don't know which part but I'm a little close

    Code (CSharp):
    1. if (battleStarted && !battleEnded)
    is this?
     
    Last edited: Oct 18, 2022
  4. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I have solved what it said
    Error CS1061 "RoundTracker" does not contain a definition for "FinalWinner" and does not contain an accessible extension method "FinalWinner" that accepts a first argument of type "RoundTracker" (are you missing a using directive or an assembly reference?)

    but I have not been able to solve what it said
    Error CS0103 The name 'CurrentWinsOf' does not exist in the current context
    Error CS0103 The name 'CurrentWinsOf' does not exist in the current context
     
  5. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    I will help you solve these errors, but thats it, send BOTH your scripts and the full error messages
     
  6. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    as it is difficult to upload the script I will only insert code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class BattleController : MonoBehaviour
    7. {
    8.     public int roundTime = 100;
    9.     private float lastTimeUpdate = 0;
    10.     private bool battleStarted;
    11.     private bool battleEnded;
    12.     public RoundTracker rt;
    13.     public Fighter player1;
    14.     public Fighter player2;
    15.     public BannerController banner;
    16.     public AudioSource musicPlayer;
    17.     public AudioClip backgroundMusic;
    18.  
    19.     public Image win;
    20.    
    21.     void Start()
    22.     {
    23.         banner.showRoundFight();
    24.         win.enabled = false;
    25.  
    26.     }
    27.     private void expireTime()
    28.     {
    29.  
    30.         if (player1.healtPercent > player2.healtPercent)
    31.         {
    32.             player2.healt = 0;
    33.             win.enabled = false;
    34.             RoundTracker.Instance.RecordRoundWinner(RoundTracker.Side.Left);
    35.         }
    36.         else
    37.         {
    38.             player1.healt = 0;
    39.             win.enabled = true;
    40.             RoundTracker.Instance.RecordRoundWinner(RoundTracker.Side.Right);
    41.         }
    42.     }
    43.  
    44.  
    45.  
    46.     void Update()
    47.     {
    48.         if (!battleStarted && !banner.isAnimating)
    49.         {
    50.             battleStarted = true;
    51.  
    52.             player1.enable = true;
    53.             player2.enable = true;
    54.  
    55.             GameUtils.playSound(backgroundMusic, musicPlayer);
    56.         }
    57.  
    58.         if (battleStarted && !battleEnded)
    59.         {
    60.  
    61.             var rt = RoundTracker.Instance;
    62.             if (rt.FinalRound())
    63.             {
    64.                 var winsTally = $"{CurrentWinsOf(RoundTracker.Side.Left)} to {CurrentWinsOf(RoundTracker.Side.Right)}";
    65.                 Debug.Log($"After {rt.TotalRounds} rounds, the winner of the " +
    66.                           $"match was the player on the {rt.FinalWinner:G}, " +
    67.                           $"with the score of {winsTally}.");
    68.             }
    69.  
    70.             if (roundTime > 0 && Time.time - lastTimeUpdate > 1)
    71.             {
    72.                 roundTime--;
    73.                 lastTimeUpdate = Time.time;
    74.                 if (roundTime == 0)
    75.                 {
    76.                     expireTime();
    77.                 }
    78.             }
    79.  
    80.             if (player1.healtPercent <= 0)
    81.             {
    82.                
    83.                 banner.showYouLose();
    84.                 battleEnded = true;
    85.                 win.enabled = false;
    86.                 RoundTracker.Instance.RecordRoundWinner(RoundTracker.Side.Right);
    87.  
    88.                 Debug.Log("Win Ken");
    89.             }
    90.             else if (player2.healtPercent <= 0)
    91.             {
    92.                 banner.showYouWin();
    93.                 battleEnded = true;
    94.                 win.enabled = true;
    95.                
    96.                 RoundTracker.Instance.RecordRoundWinner(RoundTracker.Side.Left);
    97.                 Debug.Log("Win Ryu");
    98.             }
    99.         }
    100.     }
    101. }
    102.  
     
  7. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    oh forget me if I can upload the script
     

    Attached Files:

  8. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    Omg just copy and paste the the RoundTracker.cs and BattleController.cs over here using code tags, how hard is that like seriously this even isn't funny, if this is a troll i'm going to be very angry
     
  9. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    forgive me a lot, I forgot the two scripts, it will not happen again because this is serious not fun (hate forget:mad:)
     

    Attached Files:

  10. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    Can you not copy the script and paste it, like you did before? Using code tags?
    And whats your error, send the FULL error message, I repeat, FULL
     
  11. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    this in Spanish,
    If you want, I'll translate it for you.
    Error CS0103 The name 'CurrentWinsOf' does not exist in the current context

    the problem is not that I can't upload the script in post, (because they forget me), the problem is that it says The name 'CurrentWinsOf' does not exist in the current context

    if I put in English in visual studio now it will be slower in loading the scripts (it does not matter if there is a lot of script or little)
     

    Attached Files:

  12. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    Just please


    File — New Project.
     
    Nad_B and Johan_Liebert123 like this.
  13. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I already did it, you mean Unit 1 - Player Control or or my fighting game
    .
     
  14. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    326
    :rolleyes:
     
    Johan_Liebert123 likes this.
  15. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    Anyways, I wanna end this thread good
    @orionsyndrome I love your example of your RoundTracker.cs its like, PERFECT
    Don't mind me using it for my game :):). I love your efforts in posting and helping people out, what a legend :D:D:D

    Lock the thread please
     
  16. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    326
    Hmm... well can you specify if you fixed the problems (and eventually how) so it can benefit other people?
     
  17. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    it started well, how to solve this
    Error CS0103 The name 'CurrentWinsOf' does not exist in the current context
     
  18. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    by the way, the player tag is fighter, ryu and ken if you have the fighter tag, I will submit two scripts only this time, (for spam)

    if it can be solved.
     

    Attached Files:

  19. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    No one's reading through 1000000 replies for a simple error lmfao :D
     
    Yoreki likes this.
  20. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    What do I have to do with that error?
    I have to create CurrentWinsOf in
    BattleController.cs?
     
  21. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    dude, when we finish solving this script, do we have to create a game manager?
     
  22. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
  23. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    please wait I am going to rest I don't want to end badly with this post and I don't want it to be permanently closed please I don't want this sad:(
     
    Last edited: Oct 19, 2022
  24. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,507
    Don't worry, I'm not going to lock the thread.

    I think it's clear that you are really struggling to understand some basic aspects of C#/Unity here and there is absolutely no problem with that at all, however, trying to learn this stuff in the open in a public space is going to cause frustration for both you and others who are trying to help you; the expectation is that you already have these basics/fundamentals down before you come here.

    I would strongly suggest you step back from your project and start with some structured C# basics, assuming you're not already doing that. The lure of "creating a game" style tutorial is that it can lead you into a false sense of security and you can easily get in over your head which will oobviously frustrate and demotivate you.

    There's Unity Learn and a whole host of YouTube tutorials on using C# with Unity.

    Look, this is just my advice, of course, you are free to continue trying to understand such stuff on these forums and others are free to step away but I really would suggest doing something more fundamental even if that doesn't sound very exciting. It'll pay off in the end.

    Also, yes, rest is as important as knowledge!

    Just some friendly advice! :)
     
    angrypenguin and mopthrow like this.
  25. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    Thanks, I'll fall asleep (well and relieved) because it's already 04:47 am in Argentina, I'm going to give him time to rest, and I'll think that as my answer they are very understanding
     
  26. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I apologize to everyone I made lose patience, I have a hard time understanding certain definitions because of my "autistic" condition. When I want to do something, I try and try until I achieve it, if I get very frustrated when it doesn't come out, I get intense. But I just want to learn, I need your help. (I will continue learning Junior Programmer)
     
    angrypenguin, Yoreki and MelvMay like this.
  27. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    For the stuff you're trying to do, learning fundamental programming is pretty important, as well as some maths and some other stuff.

    One thing to keep in mind is that it's a long journey. I do this stuff professionally and have well over a decade of experience and I still learn new stuff regularly.
     
    orionsyndrome likes this.
  28. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    a long journey? Do you mean I'll take 12 weeks? will take two months? that would be a bit of hell, so i'm willing to do it, in 2018 there was not that before.
     
    Last edited: Oct 26, 2022
  29. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    @Johan_Liebert123 @orionsyndrome good news, I made it work (a bit) from this RoundTracker script
    Code (CSharp):
    1. public void RecordRoundWinner(Side winner)
    2.     {
    3.         Debug.Log("Funciona");
    4.         setWins(winner, getWins(winner) + 1);
    5.     }
    I still need to make gamemanager so that it adds up the scores when winning when the scene restarts, then I will do it myself to gamemanager =( .
     
    Last edited: Oct 26, 2022
  30. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    By "it" I was referring to programming and game development overall, not just that course.

    Keep in mind that it's called "junior". It's a start, not the destination.

    But I do need to ask, if this is "a bit of hell" for you then is this really a pursuit for you? A love of playing games is very different to a love of making them. I wouldn't spend weeks learning a craft I didn't like unless I was getting paid for it. Life is too short.
     
  31. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    a search to discover, a search to make a fighting game, I would be continuing to learn junior 4-5 hours a day, and to discover about all that, I realized that I have to create a game manager to add scores to win a round like fighting game, I've seen TANKS!, it's a bit like a fighting game for the round, TANKS! Unity Tutorial - Phase 7 of 8 - Game Managers I can learn that, but I don't know what level I have to reach, I still haven't discovered how to make the game manager for round of ryu and ken.
     
  32. Strafe_m

    Strafe_m

    Joined:
    Oct 24, 2022
    Posts:
    72
    False false false false false false false and false

    That's a bad comment when referring to coding, I've spent a year of my spare time doing this and look where I am now!
     
    Last edited: Oct 26, 2022
  33. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    I wasn't talking about coding specifically. I was talking about "a bit of hell", in whatever form it may take.
     
    Yoreki likes this.
  34. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,843
    I'll give you a little bit of advice from experience here. My main impetus for learning to code and make my own games was because I wanted to make a survival craft game. I started the junior programming course - like you're doing now - and after two weeks sat down one morning and thought "I'm going to code an item an inventory system!".

    Then I very quickly realised I had no idea how to do so.

    I looked up some tutorials but they were all well, well outside my measly experience level.

    So my solution was to... put the idea to the side for the moment and continue with the programming course, tackling the small project goals it gave you.

    After a month, I believe, of learning more about Unity and about C#, I ended up being able to sit down and make my own very first rudimentary inventory system.

    Fighting games - even basic ones - look like they need a pretty decent understanding of both Unity and C#. So that's my advice: much as you want to make a fighting game I suggest putting the idea aside for now and focus on learning. Otherwise you'll just get frustrated and not go anywhere.

    What you don't know now, you will know later. Patience is key. But eventually you will learn what you need. But it likely won't happen in days or even weeks.

    Honestly the main thing that helped me learn and keep at it with C#/Unity was just patience.
     
  35. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    Thank you, spiney199.
     
    angrypenguin likes this.
  36. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,917
    Regarding the "bit of hell" comment -- and I can't speak for anyone else -- but it seems to be about how coding for games is vastly more difficult than people make it out to be.

    It's not too tough to do specific simple things, maybe from scratch, or maybe by tweaking found scripts. Sometimes you can do something a little more complicated with just a little more code. Coding seems easy.

    But then most things you want to do get very complicated, very fast, sucking in more and more concepts. And the net gets worse and worse at explaining it -- to have 10 items you need an array; no, a List; no, a Dictionary. And it needs to be a ScriptableObject; no, a dontDestroyOnLoad. But before you even do that you need to learn
    const
    , and
    enum
    ; and you have to use Properties. Plus you should be using => syntax to write functions. The net just gives more and more contradictory advice.

    Then you have to learn about Unity/game-engine stuff such as Vector3, Quaternions (to spin objects), Unity Components, the GUI system, the Physics system... .

    And then someone tells you that learning bits of "game" programming was a waste of time. If you're serious, it's really regular programming. So go find a book on that, except you're back to the same problem that everyone contradicts each other on what books are good.

    The funny thing is, Unity originally told it like it was. They said "we assume you already know computer or game programming. If don't and want to learn, we recommend this University textbook that normally takes an 18-year-old a semester to learn". But then so many sites had "learn to code in Unity in 5 easy lessons" and muddied it all up until even Unity Co. gave in.
     
  37. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    the truth, I wasn't starting to make a small fighting game (Now!), I was making a small fighting game (pacing) using ryu and ken for testing, I thought it would be a form of practice and it wasn't, even if I'm still waiting again the hope of how to do round as mk or sf with game manager, I already left my project aside.
     
  38. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I know what const, and enum; => syntax i will try to learn how to use syntax (a bit more).
     
  39. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,917
    No, don't. Those are time-wasters. I was saying that when you try to learn programming, people tell you about lots and lot of time-wasting stuff. That makes it hard to learn programming.
     
    AnimalMan likes this.
  40. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    so i keep learning the basics.
     
  41. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    It's not because no one wants to work with me, the reason is because I don't know anyone who knows how to program in unity, I thought joining the unity forum was going to help me, until angrypenguin came along and gave me the official unity websites to learn again the Basics, the recommendation of those sites to start learning again.
     
  42. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,589
    Why on earth are you replying to that now? I think the comment in question is on the front page.
     
  43. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I'm sorry, I didn't want to forget this answer this time
     
  44. TheFighterSFMK2022

    TheFighterSFMK2022

    Joined:
    Oct 1, 2022
    Posts:
    144
    I am learning the basics of programming that has nothing to do with the unity engine, I took your advice to start, let my fighting game rest, I hope I can move on with my fighting game and return to the program with the fighting game, I was celebrating that Argentina won the world cup in qatar 2022:), what a pity that you did not win your country, I did not come to talk about that :(, I came to speak to leave a fight game program, the truth is that I was waiting for @Johan_Liebert123 when I told him.
    I was expecting him to say no, I'm not going to beg anything, even currently I can't solve the round system problem, if someone wants to waste time with me to solve the round system problem (24 hours) I'll be ready, yes I already know what nobody wants to waste time with me (24 hours), only if they are bored and they have nothing to do because they have no idea to do or whatever I will be there (if you want this 24 hours solving), anyway I hope to solve the round system and continue learning the basics of programming that it has nothing to do with the unity engine very sad :(, Surely I will leave the forum again until it is resolved or someone, if they want, spends 24 hours with me trying to solve the round system You can say that you don't want to spend 24 hours with me solving this round system that I'm not going to beg you to do:(.
     
    Last edited: Dec 20, 2022
  45. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    326
Thread Status:
Not open for further replies.