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
0
Question by Sinron · Oct 09, 2012 at 05:02 AM · jumpinginput managergetbutton

Function GetButton only returning once?

I'm trying to use Input.GetButton() to have my player jump however it seems that this button is only returning once per run. I'm not sure why this would be doing that below is the code which is fairly simple.

Also if it helps Jump is looking at the Xbox Controllers Joystick Button 0 which is A.

  if (Input.GetButton("Jump"))
         {
             Jump();
         }
Comment
Add comment · Show 1
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 Eric5h5 · Oct 09, 2012 at 05:03 AM 0
Share

Not enough info. In what function is the code? Also, you'd want to use GetButtonDown and not GetButton.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by CodeMasterMike · Oct 09, 2012 at 06:55 AM

I'm not sure, but I think that the GetButtonDown/GetButtonUp only fires once per inut. So it doesn't check if the button is pressed down all the time or not.

What you can use instead is the GetAxis() function, which normally has a value between -1 and 1 (0 being not pressed at all). The jump, by default, goes between 1 and 0.

This means that it will react as long as you have the button pressed down, unlike the GetButton function. So you can do something like this:

 if(Input.GetAxis("Jump") != 0)
 {
    Jump();
 }
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 whydoidoit · Oct 09, 2012 at 06:57 AM 1
Share

GetButton does check every frame... As @Eric5h5 mentions - it's probably not what the OP wants though, there must be some other logic problem in code we can't see.

avatar image
0

Answer by Sinron · Oct 09, 2012 at 04:07 PM

Actually you are correct in stating that it does check every frame. After a few more hours and the simplest bug checking method i discovered the problem was in the logic of my code. All i had to do to see if it was the button or other code was Print("Button Pressed"). After doing so i discovered my error was in multiplying the power in the vectors Y force by Time.DeltaTime in this function. Thanks for the help though it's my fault for not trying the print debug method right off the bat.

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

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

13 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

Related Questions

Jumping Issue, Need Help. 0 Answers

Why can't I properly jump? 2 Answers

How to prevent player from moving in air while jumping in place ?? 0 Answers

I`m not able to jump 1 Answer

Why is enemy jumping at different speed even though the velocity is the same? 0 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