Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by AnmolXP · Oct 27, 2017 at 07:21 AM · timedamagecombo

Help with system inputs for a combo game.

I want to build a game based on DDR, where user has to type in a combo and if done correctly and fast enough it will damage the enemy. If a error is made or combo done to slow player will take damage.

I am struggling to grasp how to setup the combo system and have it load a new combo after damage is dealt.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class ComboBreaker : MonoBehaviour {

 public GameObject Set1P;
 public GameObject Set2P;
 public GameObject Set3P;
 public GameObject Set4P;
 public GameObject Set5P;
 public GameObject Set6P;
 public GameObject Set1E;
 public GameObject Set2E;
 public GameObject Set3E;
 public GameObject Set4E;
 public GameObject Set5E;
 public GameObject Set6E;

 public int PlayerHP = 5;
 public int EnemyHP = 5;

 public KeyCode[] combo;
 public int currentIndex = 0;


 void Start()
 {
     //StartCoroutine(functionName());

     Set1P = GameObject.FindGameObjectWithTag("S1P");     // Get all Combo Sets s1p= Set One Player/ s1e = Set One enemy
     Set2P = GameObject.FindGameObjectWithTag("S2P");
     Set3P = GameObject.FindGameObjectWithTag("S3P");
     Set4P = GameObject.FindGameObjectWithTag("S4P");
     Set5P = GameObject.FindGameObjectWithTag("S5P");
     Set6P = GameObject.FindGameObjectWithTag("S6P");

     Set1E = GameObject.FindGameObjectWithTag("S1E");
     Set2E = GameObject.FindGameObjectWithTag("S2E");
     Set3E = GameObject.FindGameObjectWithTag("S3E");
     Set4E = GameObject.FindGameObjectWithTag("S4E");
     Set5E = GameObject.FindGameObjectWithTag("S5E");
     Set6E = GameObject.FindGameObjectWithTag("S6E");

 }

 void Update()
 {

     if(EnemyHP > 0 || PlayerHP > 0)
     {

         System.Random rand = new System.Random();//get random variable for set
         int set = rand.Next(1, 2); // random between 1 and 6, only using one to test with 

         if (set == 1)    // Random = 1, Show Set 1 and complete there will be 6
         {
             Set1P.SetActive(true); // Set Active both set 1's
             Set1E.SetActive(true);
             Set2E.SetActive(false);
             Set3E.SetActive(false);
             Set4E.SetActive(false);
             Set5E.SetActive(false);
             Set6E.SetActive(false);
             Set2P.SetActive(false);
             Set3P.SetActive(false);
             Set4P.SetActive(false);
             Set5P.SetActive(false);
             Set6P.SetActive(false);


             int AIspeed1 = rand.Next(1, 4);  // time between 1 and 3 sec/key
             int AIspeed2 = rand.Next(1, 4);
             int AIspeed3 = rand.Next(1, 4);
             int AIspeed4 = rand.Next(1, 4);
             float AIcomplete = AIspeed1 + AIspeed2 + AIspeed3 + AIspeed4; // Ai's time to complete combo player must complete faster

             AIcomplete -= Time.deltaTime;

             if (Input.GetKeyDown(KeyCode.DownArrow) && AIcomplete > 0) // if key correct go to next or take damage
              {
                  if (Input.GetKeyDown(KeyCode.LeftArrow) && AIcomplete > 0)
                  {
                      print("Left key pressed");
                      if (Input.GetKeyDown(KeyCode.UpArrow) && AIcomplete > 0)
                      {
                          print("up key pressed");
                          if (Input.GetKeyDown(KeyCode.RightArrow) && AIcomplete > 0)
                          {
                              print("right key pressed");
                              --EnemyHP;
                          }
                          else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow))
                          {
                              --PlayerHP;
                          }
                      }
                      else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.DownArrow))
                      {
                          --PlayerHP;
                      }
                  }
                  else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow))
                  {
                      --PlayerHP;
                  }
              }
              else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.RightArrow))
              {
                  --PlayerHP;
              }

             if (PlayerHP <=0 || EnemyHP <= 0)
             {
                 GameOver();
             }

             print("looped");
         }
     }
     

 }

 void GameOver()
 {
     Time.timeScale = 0;
     //set GameOver Active
 }
 

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

118 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make the enemy's damge be time based and showing? 0 Answers

Fixing Animation calls in a combo Script 0 Answers

Need help with combo based game input and damage systems. 0 Answers

Health variable not changing 1 Answer

How to make a timer that counts up in seconds, as an int? 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges