Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by IKilledKenny_2 · Jan 27, 2015 at 01:05 AM · javascriptraycaststringcombo

Combo Script Problem

Hello Unity3D.I have a problem with my combo script.Anytime i put my combo script into my character.My character freezes and is not able to do the combo or anything at all.If anyone knows why this problem occurs.Can anyone please tell me why?(I have been stuck on this for 2 weeks now....)

P.S Heres a script i have been trying to get with

 #pragma strict  
 var recordInput : String = "";
 var waitClearSeconds : float = 1; //wait 1 second adter the last input before clear, you will have to adjust this setting later
  
  function Update() {
  
  RecordInput();
  
  waitClearSeconds -= Time.deltaTime; 
  
  if(waitClearSeconds < 0f) {
  GetCombo();
  Clear();
                      }
  }
  
  function RecordInput() {
  
  Input.GetKeyDown("k"); 
  {
  animation.Play("Rex_Sword_Kick");
  recordInput += "k";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  }
  Input.GetKeyDown("k");
  {
  animation.Play("Rex_Sword_Kick_2");
  recordInput += "kk";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  }
  Input.GetKeyDown("k");
  { 
  animation.Play("Rex_Seal_Combo");
  recordInput += "kkk";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  
      }    
  
  
  }
  
  
 function GetCombo() {
  
 if(recordInput == "kkk") 
  
 Input.GetKeyDown("p");
 {
 animation.Play("Spinning_Slashes");
 recordInput += "kkkp";
 waitClearSeconds = 0.2f;
     }
 }
 function Clear() {
 recordInput = "";
  
  }
  
Comment
Add comment · Show 3
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 meat5000 ♦ · Feb 02, 2015 at 11:53 PM 1
Share

You appear to be missing a bunch of if statements around your Inputs.

I believe no-one has looked at it due to the title.

avatar image Inan-Evin · Feb 02, 2015 at 11:56 PM 0
Share

this is what you should do to check if a key is pressed

 if(Input.Get$$anonymous$$eyDown("key")) 
 {
 // your code here
 }
avatar image IKilledKenny_2 · Feb 03, 2015 at 12:23 AM 0
Share

@ meat5000 oh yea sorry....I forgot to change it ;-;....

@Inan Evin i did it but the player still doesnt move...

 #pragma strict  
 var recordInput : String = "";
 var waitClearSeconds : float = 1; //wait 1 second adter the last input before clear, you will have to adjust this setting later
  
  function Update() {
  
  RecordInput();
  
  waitClearSeconds -= Time.deltaTime; 
  
  if(waitClearSeconds < 0f) {
  GetCombo();
  Clear();
                      }
  }
  
  function RecordInput() {
  
  if(Input.Get$$anonymous$$eyDown("k")); 
  {
  animation.Play("Rex_Sword_$$anonymous$$ick");
  recordInput += "k";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  }
  if(Input.Get$$anonymous$$eyDown("k"));
  {
  animation.Play("Rex_Sword_$$anonymous$$ick_2");
  recordInput += "kk";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  }
  if(Input.Get$$anonymous$$eyDown("k"));
  { 
  animation.Play("Rex_Seal_Combo");
  recordInput += "kkk";
  waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
  
      }    
  
  
  }
  

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Derek-Wong · Feb 03, 2015 at 02:13 AM

your 3 if statements are checking the same conditions...so they will all triggered when you press k

Comment
Add comment · Show 1 · 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 IKilledKenny_2 · Feb 03, 2015 at 03:08 AM 0
Share

It Still didnt work DX.....Why is this so hard?!

 #pragma strict  
 var recordInput : String = "";
 var waitClearSeconds : float = 1; //wait 1 second after the last input before clear, you will have to adjust this setting later
  
  function Update() {
  
  RecordInput();
  
  waitClearSeconds -= Time.deltaTime; 
  
  if(waitClearSeconds < 0f) {
  GetCombo();
  Clear();
                      }
  }
  
  function RecordInput() {
  
  if(Input.Get$$anonymous$$eyDown("k")); 
  {
  animation.Play("Rex_Sword_$$anonymous$$ick");
  recordInput += "k";
  waitClearSeconds = 0.1f; //reset the wait time to avoid clearing too early
  }
  {
  animation.Play("Rex_Sword_$$anonymous$$ick_2");
  recordInput += "kk";
  waitClearSeconds = 0.2; //reset the wait time to avoid clearing too early
  }
  { 
  animation.Play("Rex_Seal_Combo");
  recordInput += "kkk";
  waitClearSeconds = 0.3f; //reset the wait time to avoid clearing too early
  
      }    
  
  
  }
  
  
 function GetCombo() {
  
 if(recordInput == "kkk") 
  
 if(Input.Get$$anonymous$$eyDown("p"));
 {
 animation.Play("Spinning_Slashes");
 recordInput += "kkkp";
 waitClearSeconds = 0.4f;
     }
 }
 function Clear() {
 recordInput = "";
  
  }
  
 

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

22 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

Related Questions

Combo Script Problem 1 Answer

Cable-building simulations. 0 Answers

Raycast script help? 1 Answer

Make tranform follow raycast 1 Answer

get all text between two chars (js) 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