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
0
Question by MnzrAbusham · Jun 18, 2018 at 07:28 PM · fpsgamecontroller

Ignore Xbox 360 controller joystick when it re-centers (returns to 0),Xbox 360 joystick input returning to 0

In my FPS game, I am trying to move a crosshair with my right joystick. The problem I am running into is that the read input of the joystick always returns to 0 when the it re-centers. I want the crosshair to move as I move the joystick and then stop when I release it, and not go back (snap) to the center of the screen or where the movement started. I am currently used Input.GetAxis("Horizontal").

I believe lots of games do this with their cameras and crosshairs. the game reads the joystick input when moving but then ignore it when returning to center. Below is my Code

 void Update () {
 
         float hAxis = Input.GetAxisRaw("AimJoystickHorizontal");
         float vAxis = Input.GetAxisRaw("AimJoystickVertical");
 
 Vector2 stickInput = new Vector2(vAxis * 30, hAxis * 30); 
  // Here, I am just trying to formulate a good deadzone value     
  if (stickInput.magnitude < deadzone)
             stickInput = Vector2.zero;
         else
             stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone));
 
  Rotation = Quaternion.Euler(stickInput.x, stickInput.y, 0);
 
 //This is How I transform the crosshair
 crosshair.transform.position = cameraFacing.transform.position +
             cameraFacing.transform.rotation * Rotation * Vector3.forward * distance ;
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 nomadic · Jun 18, 2018 at 07:43 PM

Check out the settings for the Horizontal axis input in InputManager. https://docs.unity3d.com/Manual/class-InputManager.html

Try playing with Gravity, Sensitivity, and Dead. Most notably, Gravity will allow you to increase the snappiness, or how quickly the axis value will return to zero.

Comment
Add comment · Show 5 · 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 MnzrAbusham · Jun 18, 2018 at 07:53 PM 0
Share

Gravity option doesn't apply when the input is read from a joystick axis. I am already content with the sensitivity and dead values. I just want the input to ignore the joystick returning to center. just like what happens in games when the controller's joystick is used to move the camera. The camera moves when you push the joystick but then doesn't return to it's original position when the joystick re-centers.

avatar image nomadic MnzrAbusham · Jun 18, 2018 at 07:59 PM 0
Share

Wait, how are you applying axis input to your camera rotation? If you add rotation to the camera based on axis input then it should work like you describe.

avatar image MnzrAbusham nomadic · Jun 18, 2018 at 08:06 PM 0
Share

Sorry, I should've included my code from the beginning. It's updated now. The last part is how I apply the rotation.

Show more comments

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

152 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

FPS controller, only for use on object 0 Answers

How can i make levels to a fps game 1 Answer

newbie here [NEED HELP] 2 Answers

Objects stutter when using First Person Controller? 4 Answers

Referencing an object from one script to another, script reference doesn't help :/ 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