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 /
avatar image
-1
Question by awplays49 · Jan 04, 2015 at 07:12 PM · jumpdelay

Delay jump to confirm player really wants to jump

so that after the player has held space for 0.25 seconds, jumping = true :)

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 JeevanjotSingh · Jan 04, 2015 at 07:15 PM 0
Share

can you define it a little more , is the space means a keyboard key or just a platform space . Then what you actually want is the player doesn't react until 0.25 sec after when space pressed and then jump or jump = true . If yes then you will find my answer helpful .

avatar image awplays49 · Jan 04, 2015 at 07:17 PM 0
Share

space key. i want the player to have to hold space for 1/4 of a second before it jumps. but i want the player to not just be able to hit jump, then hit it 1/4 second after, thats why a coroutine doesn't work.

avatar image JeevanjotSingh · Jan 04, 2015 at 07:21 PM 0
Share

Now i got it looks invoke also not works for this . I have to find out other solution for this .

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JeevanjotSingh · Jan 04, 2015 at 07:20 PM

just use update() function .

and in update use something like

 public bool jumping = false;
 
 void update()
 {
 if(Input.GetKeyDown(KeyCode.Space))
 {
     Invoke("TheFunction",0.25f);
 }
 }
 
 void TheFunction()
 
 {
 jumping = true;
 }

Not tested but , looks like it works

let me know if it works or not .

Comment
Add comment · Show 5 · 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 awplays49 · Jan 04, 2015 at 07:21 PM 0
Share

thank you!

avatar image MiniFish · Jan 04, 2015 at 07:26 PM 0
Share

doesn't this cause the player to jump after 0.25 seconds, even if the player didn't want to? you might want to add a cancel invoke function during Get$$anonymous$$eyUp to cancel the jump if they player only tapped the space key.

avatar image JeevanjotSingh · Jan 04, 2015 at 07:31 PM 0
Share

No problem and let me know if the first code works , if not i will insert this code with one more condition to identify invoke .

 if(Input.Get$$anonymous$$eyUp(keycode.space))

{ CancelInvoke("TheFunction") }

avatar image JeevanjotSingh · Jan 04, 2015 at 07:39 PM 0
Share

I also got another solution with time delay .

use Input.Get$$anonymous$$ey($$anonymous$$eyCode.Space) ins$$anonymous$$d Get$$anonymous$$eyDown() and on each frame add time.delta time to float and if it will == or >= 0.25 then player can jump or jump == true , if not them just continue the game .

avatar image JeevanjotSingh · Jan 04, 2015 at 08:33 PM 0
Share

"No, it never jumps because it invokes jump while space is held"

That's why now i am not preferring the invoke or cancel invoke (because it didn't make any sense to hold the button) but as i explained other way you can try that and tell if you have any problem with the new code about use Input.Get$$anonymous$$ey($$anonymous$$eyCode.Space) etc.....

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

26 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

Related Questions

need to create delay, for something that will execute every frame, for a bit of time 1 Answer

How Would I Add A Delay Between Jumps . 3 Answers

Time Delay Animation 1 Answer

How can I set a timer? 1 Answer

Coroutine doesnt work. Delayed Jump. 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