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 uwakaronai · Jan 25, 2021 at 06:02 AM · inputmouseinput manager

why input isn't working correctly?

Curious to know what could be affecting my keyboard input. I made some scripts to control movements and actions for a 2D game using the 2017.3.1f1 unity editor.

For several hours I've tried debugging my issue, which is: after pressing a jump key another key press isn't getting evaluated. I made a counter after the Input.GetButtonDown call just to be sure and it doesn't count until after he player has hit ground again. It doesn't occur with any other inputs, just after the "Jump". I also found some code to log the keys pressed and stored 10 key presses to a string and logged it, same results.

I did notice that if constantly jumping around eventually the button press does get returned, but the issue returns immediately after stopping.

Just for kicks, I plugged in my Xbox controller and had no issue whatsoever, and my scripts function as expected. Is my computer doing this, or what might be going on?

I just now checked the primary positive Fire1, and it also works as expected. The alt (mouse0) button is the one presenting the symptom.

Any help understanding this would be greatly appreciated.

Thanks

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 john_unity389 · Jan 25, 2021 at 08:45 AM 0
Share

Chances are it's your keyboard not working properly, could you post your script here?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by uwakaronai · Jan 25, 2021 at 07:40 PM

@john_unity389 Thanks for replying. Unfortunately, I don't have internet. I will post what I can and shorthand it where possible. I know I should be using a desktop for this but you get by with what you got. My mouse is a touchpad. It just seems weird how the problem manifested, unless it was getting conflicting input that has no keyCode from the mouse.

No worries if you don't want to continue reading this. But, if you're interested in questioning my scripts, I can give you an idea what they do. Bear in mind, I'm a noob and I'm not crunching to finish a project just trying to get better at programming an understand how unity works, so I may doing things that can be done more easily with the GUI purposely.

I basically have three scripts to control player movement, animations, and actions. They talk to each other a little bit. -The movement script stores a string of the base layer animation state, which has idle walking jumping or falling.

[NonSerialized] string baseState="idle"; Update(){ProcessInputs} ProcessInputs(){ If (condition){baseState="walking" }else{baseState="idle"; }}

-The actions script stores 2 strings, one for the action of the input and one for the layer that the animation state is on. I'm not sure if it's the way I want the animations controlled yet.

[NonSerialized] string layer="base"; [NonSerialized] string "idle"; Update(){ ProcessInputs(); SetToBase(); } ProcessInputs(){ If (Input.GetButtonDown("Fire1")){ action="throw"; layer="arms"; }else if (layer !="base"){ action="idle"; }} SetToBase(){ if (action=="idle"){ layer="base"; }}

-The animator script takes the state name from the movement script and the layer and action from the actions script in update. It plays the state if the layer is not the base layer, otherwise it plays the state from the movement script.

Start and Update()- use getcomponent<>() for the NonSerialized variables. activeLayer = layer from actions action = from actions state = base state from movement

Animate(){ If( activeLayer !="base){ anim.Play(action, anim.GetLayerIndex(activeLayer)); }else{ anim.Play(state); }}

I used a separate state behavior script on the action state to set the layer weight to 1 and 0 respectively on enter and exit for the animation state.

Thanks, Ben

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 uwakaronai · Jan 25, 2021 at 07:43 PM 0
Share

Sorry, didn't realize the enter key wouldn't make a new line.

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

147 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

Related Questions

C# Mouse Look (Input.GetAxis("MouseX&Y")) 0 Answers

Create new InputManager entry? 2 Answers

Touch inputs on a Desktop type device 2 Answers

Baffling Input.Mouseposition problem. If statement not correctly working. 1 Answer

How to Move a Cube 3 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