Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by andre-ivankio · Apr 06, 2010 at 12:11 AM · editorinput

3dconnexion - Delta joystick input

How to properly get the delta input from the 6 joystick axes?

I am trying at least to implement the space navigator in the runtime camera. It works, but I need help with the absolute values of axes input.

Because of the absolute axis, I had to do that oldVector dirty workaround. One problem is that it would be even dirtier to implement the filtering off of small inputs.

Another problem is that it will stop working whenever I go beyond 1 or -1 on any axis. I needed to set sensitivity very low, but it will still reach a cap.

I believe I'm overlooking some basic Unity functionalities, am I? I've seen some hints about mouse delta input, but I couldn't find it how to set for this case.

// INPUTS: // // joyX = X axis // joyY = 3rd axis * invert // joyZ = Y axis * invert // tilt = 6th axis // pan = 4th axis * invert // roll = 5th axis // // all sensitivity set to 0,001

var translateSpeed = 100.0; var rotateSpeed = 100.0;

private var joyTrans = Vector3(0,0,0); private var joyRotate = Vector3(0,0,0);

private var joyOldTrans = Vector3(0,0,0); private var joyOldRotate = Vector3(0,0,0);

private var texto = "monitor";

//@script AddComponentMenu("Camera-Control")

function OnGUI () { texto = joyTrans.ToString(); GUI.Box (Rect (10,10,200,20), texto); texto = joyRotate.ToString(); GUI.Box (Rect (10,30,200,20), texto); }

function Start () { joyTrans.x = Input.GetAxis("joyX"); joyTrans.y = Input.GetAxis("joyY"); joyTrans.z = Input.GetAxis("joyZ"); joyOldTrans = joyTrans;

joyRotate.x = Input.GetAxis("pan"); joyRotate.y = Input.GetAxis("tilt"); joyRotate.z = Input.GetAxis("roll"); joyOldRotate = joyRotate; }

function LateUpdate () {

   joyOldTrans = joyTrans;
   joyTrans.x = Input.GetAxis("joyX");
   joyTrans.y = Input.GetAxis("joyY");
   joyTrans.z = Input.GetAxis("joyZ");

   joyOldRotate = joyRotate;
   joyRotate.x = Input.GetAxis("pan");
   joyRotate.y = Input.GetAxis("tilt");
   joyRotate.z = Input.GetAxis("roll");

   var position = (joyTrans-joyOldTrans) ;
   var rotation = (joyRotate-joyOldRotate);
   position *= 1*translateSpeed;
   rotation *= 36*rotateSpeed;

   transform.Translate (position);
   transform.Rotate (rotation);

}

I also guessed that the call bellow should reset the all axes to 0, but it did not when I put it on the start function.

Input.ResetInputAxes();

Comment
Add comment · Show 5
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 skovacs1 · Sep 24, 2010 at 07:21 PM 0
Share

Not quite sure I follow. What exactly "will stop working whenever [you] go beyond 1 or -1 on any axis"? How/where do you even go beyond 1 or -1? What do you mean by "absolute Value"? Input.GetAxis for Joysticks (per the docs) returns a smoothed value indicating current state. Input. Input.GetAxisRaw will return non-smoothed values.

avatar image skovacs1 · Sep 24, 2010 at 07:22 PM 0
Share

Have you tried setting the position and rotation rather than calculating a translation (transform.position = joyTrans translateSpeed;transform.eulerAngles = joyRotate rotateSpeed;) to visualize how your axes are positioned? This should accomplish the same as your translation/rotation etc.

avatar image skovacs1 · Sep 24, 2010 at 07:27 PM 0
Share

The docs say "Note also that the Input flags are not reset until "Update()", so its suggested you make all the Input Calls in the Update Loop." Perhaps because you put the call in Start(), it did not perform as you expected? ResetInputAxes will set the axes to 0 for one frame only and, with the code above, the object would translate to mimic the position of the joystick as the code would have it do normally as the delta from 0 to the current position will be the current position.

avatar image Jean-Fabre · Nov 12, 2010 at 06:54 AM 0
Share

What joystick are you using, then if we have the same joystick we can compare results and pin point the problem. I for example have a logitech gamepad with 6 axis and all is working fine on all axis.

avatar image ilexius · Jan 31, 2012 at 01:25 PM 0
Share

Have you solved your problem? I am facing the same problem...

0 Replies

· Add your reply
  • Sort: 

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

1 Person is following this question.

avatar image

Related Questions

How to check if a key is down in editor script 2 Answers

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

customization of variables in script for in Editor? 2 Answers

[Unity Editor] Emulate Touch Input - Still Asking 12/10 1 Answer

Update - Delaying until next frame? 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