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

How do i create an intricate combo system for my 2d platformer game ?

Discussion in 'Scripting' started by TheRoofyDude, Aug 10, 2022.

  1. TheRoofyDude

    TheRoofyDude

    Joined:
    Aug 2, 2019
    Posts:
    4
    I want to create a combat system similar to platinum games or the DMC series, where my player character can execute different attack combos based on the combinations of buttons pressed.

    I have watched many tutorials on the subject, but most of them only teach you how to execute 3 attack animations when the same button is pressed (e.g. pressing x three times). I want to learn how to create a system that is easily extensible and can create different combos (e.g. pressing x 2 times and y 1 time).

    How do I do implement such a system ?

    P.S I am using an event-based architecture, where all outputs are sent as events and input is received through functions. I am also using a script animation controller instead of Unity's animation controller.
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,596
    You probably want some kind of state-machine to keep track of your current move, and what moves you can move into.
     
  3. TheRoofyDude

    TheRoofyDude

    Joined:
    Aug 2, 2019
    Posts:
    4
    How do i implement such a state machine ?, any tutorial on how to get started on state machines ?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    THOUSANDS.

    There's also thousands of tutorials out there for every form of game imaginable, even 2D platformers and games with "intricate combos."

    When you get around to actually doing some of the thousands of tutorials out there, make sure you do them properly:

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!

    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!
     
  5. TheRoofyDude

    TheRoofyDude

    Joined:
    Aug 2, 2019
    Posts:
    4
    Thank you very much man, you have given me a new perspective on doing things. i will do this
     
    Kurt-Dekker likes this.