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 /
avatar image
0
Question by mealone · Nov 04, 2016 at 04:10 PM · c#scripting problemcombo

help with scripting combo

Hello all,

I am seeking help with developing a combo system. I have buttons in the game for the directions up, down, left, right, up left, up right, down left, and down right. I have boxes in the game which are obstacles, and there would be a combination on the boxes in order to break or destroy them so that the character can continue to move. so an example would be something like this: Three boxes in the game. The first box has a generated combo of 3 moves, which would be pressing the buttons [down, right, left]. The second box would have a combo of 2 moves [up, down]. The third box would have a combo of 5 moves [down, up left, down, right, left].

what I would like is that when the buttons are touched the combo would begin to have the boxes destroyed, but the boxes would not be destroyed unless the combo has been completed, and that every time a correct input is entered in the combo code for the box, a dust vxf prefab would be spawned. An example for box 2 would be: Player presses "up" button, the combo begins, and dust prefab is instantiated. Player presses down button, combo is complete and box is destroyed.

I would also like for the combo to only begin once the first character has been entered correctly, and that it would follow the particular sequence until completion.

Comment
Add comment · Show 2
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
avatar image mealone · Nov 04, 2016 at 11:45 PM 0
Share

help please?

avatar image Zitoox mealone · Nov 04, 2016 at 11:53 PM 0
Share

Complex script. $$anonymous$$aybe someone is creating it for you right now, it's just difficult to make a script that allow you to do that within 7 hours.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kamil1064 · Nov 05, 2016 at 10:32 AM

@mealone, check this out http://answers.unity3d.com/questions/1156608/random-keys-combo.html#comment-1157728

Comment
Add comment · Share
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
avatar image
0

Answer by Rekrahttam1 · Jan 30, 2017 at 07:35 AM

I know this is a bit old, but to give you a direct answer:

Place this code on each box and set the dust and destruction prefabs. The KeyCode array sequence contains the list of required key presses.

 public Transform dustEffect;
 public Transform destroyEffect;
 KeyCode[] sequence = new KeyCode[3] {KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.LeftArrow};
 int current = 0;

 void Update() {
     if (Input.GetKeyDown(sequence[current])) {
         Instantiate(dustEffect, transform.position, transform.rotation);
         current++;

         if (current == sequence.Length) {
             Instantiate(destroyEffect, transform.position, transform.rotation);
             Destroy(gameObject);
         }
     } else {
         current = 0; //causes sequence to restart if wrong key is pressed.
     }
 }

This will destroy all boxes that have the sequence, so if you only want one box active at a time, add:

 bool isActive = false;

 void Activate() {
     isActive = true;
 }

and modify the first if statement to:

 if (Input.GetKeyDown(sequence[current]) && isActive) {

Then just call .Activate() on each box when you want it to become active.

A simple function to randomly generate a key sequence is easy to write, or one to set from a master function.

Comment
Add comment · Share
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

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

242 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Mirror : How to Sync child objects active status on join? 0 Answers

Make event stop 3 Answers

How would I make a ListChangedEvent? 1 Answer


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