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 muzboz · Apr 18, 2013 at 04:31 PM · triggerjoystickmacxbox controller

Xbox 360 Controller (on Mac): Trigger initialises at "0" at game startup, but trigger itself is at position "-1", how can I get the correct value at startup?

How do I reconcile the fact that on Mac, the right trigger of an Xbox 360 controller returns a value of "0" when the game first begins, but the trigger axis itself is not being pressed and should initialise with a value of "-1".

Currently, I have to press the button once, then release it, then it gives me the proper -1 value. But when the game first starts, it's giving me the wrong value.

I want my character to jetpack around, and I'm trying to use the right trigger to return a value from 0 to 1.

I do a Math.Lerp to get the right trigger (on Mac this is called Axis 6) to turn the -1 to +1 range to a 0 to 1 range.

It all works great, except that when I start the game, my character immediately starts using their jetpack, because the controller says that the triggers are at position "0", when actually, they're at position "-1", because they're not being pressed.

Once I press the triggers, they reset properly, and give values -1. I just don't know how to force the controller to give a proper -1 reading at game startup! Any ideas?

  • Murray

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 muzboz · Apr 18, 2013 at 02:20 PM 0
Share

Ahhh, after several hours of bashing my head against this problem, I think that posting it here helped me figure out a solution!

I just created a variable called ReadyToThrust = false.

The jetpacking controls do not start updating until this is true.

I set it to true only...

 if (Axis 6 > -0.9) && (Axis 6 < -0.2).

That prevents "0" from triggering the jetpack updates. The player needs to press the trigger a little before ReadyToThrust is set to true, and then they can start jetpacking around as per usual!

Done!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mcteapot · Aug 26, 2013 at 04:48 AM

I ran into the same issue, in addition I needed to normalize the numbers between 0-1.

Here is the code I used to fix it, hope someone finds this useful.

 float macReadTrigger () {
     
     float adjustedAxis = 1.0f;
     timeAxis = Input.GetAxisRaw("Trigger");
 
     if((timeAxis > -0.9f && timeAxis < -0.0001f) && readyToShiftTrigger == false) {
         readyToShiftTrigger = true;
     }
     
     if(readyToShiftTrigger) {
         //Debug.Log("TIME SHIT: " + timeAxis);
         if(timeAxis == -1) {
             adjustedAxis = 0;
         } else if(timeAxis > -1 && timeAxis < 0) {
             adjustedAxis = (timeAxis * -1.0f) * 0.5f;
         } else if(timeAxis == 0) {
             adjustedAxis = 0.5f;
         } else if(timeAxis > 0 && timeAxis < 1) {
             adjustedAxis = (timeAxis + 1.0f) * 0.5f;  
         } else if(timeAxis == 1) {
             adjustedAxis = 1;
         }
         
     }
     
 
     return adjustedAxis;
 }
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 karlhulme · Sep 06, 2014 at 02:17 PM 0
Share

Hi, the 5 IF statements can be replaced with: adjustedAxis = (timeAxis + 1) * 0.5;

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

12 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

Related Questions

Tattie Bogle doesn't distinguish between multiple Xbox 360 controllers for Mac OS X El Capitan 0 Answers

In-app purchase "Invalid product" on Mac Store build 0 Answers

Joystick Throttle Contol 0 Answers

Mac xbox controller detect trigger input 1 Answer

getAxis problem going from mac to pc 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