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 Dan 12 · Nov 30, 2010 at 11:06 AM · inputjoystickkeyboard

Storing Joystick movements, key depressed time

I have need to record both the length of time a key has been depressed for, and expanding beyond this to store joystick movements. What data type and method can I use to store joystick movements?

I am trying to apply an equal and opposite force automatically to an object by creating a method that will run upon user key or joystick input and apply the opposite of input after input ceases.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Proclyon · Nov 30, 2010 at 11:28 AM

Use the input manager built into Unity3D (Edit -> Project Settings -> Input) The keys defined here have a couple of variables that I think have exactly what you need. The reference to what they are you can see here

Btw nice title, I didn't know keys could be sad.

EDIT:

If you want to make your own code

Get 2 states stored

Pressed this frame Pressed previous frame

if !pressed previous frame and pressed this frame means key is held down while it's held down ( update routine) Increase a time value. And presto chango you have a measurement system in code for the time it has been measured Just don't forget to reset it if needed.

Comment
Add comment · Show 2 · 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 Dan 12 · Dec 03, 2010 at 04:11 PM 0
Share

I can see how the code for keys will work with thanks.

I'm not so clear as to recording joystick movements, I realise I can GetAxis(Horizontal) etc every frame but here is what I am trying to achieve more specifically:

If the joystick is moved in a given axis away from zero value, or out of the deadzone value, I want to store those values so that when the input returns to less than the deadzone again, the values can be automatically applied back in a scripted method in the opposite direction. For example a small amount of thrust input from joystick will be applied after the axis is idle?

avatar image Dan 12 · Dec 03, 2010 at 04:12 PM 0
Share

I think with the amount of coffee spillage my keys are hypertensive ;)

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

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Where can I find a list of characters sent from when pressing key? Examples of characters are: "\b" "\n" 1 Answer

Input.GetButtonDown not working at ALL 1 Answer

How to make a joystick axis input equivalent to keyboard input. 1 Answer

How to detect value changes in new input system 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