Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 jdelaay025 · Jul 28, 2015 at 09:11 PM · movementjoystickinputmanager

My input manager doesn't always respond to my code

I use joysticks and keyboards for testing. I recently had my player moving just fine. He would move forward and rotate with the left right stick like your standard 3rd person shooter or fps. But I could not strafe. So I looked at a tutorial on how to have complex movement with both the x and y axis. the code is:

 Vector3 horizontalInput = new Vector3 (Input.GetAxis ("RotateH"), 0, Input.GetAxis ("RotateV"));
         Debug.Log (Input.GetAxis ("RotateH"));
         if (horizontalInput.magnitude > 1)
             horizontalInput.Normalize ();
         Vector3 targetHorizontalMovement = horizontalInput;
         targetHorizontalMovement = cameraTransform.rotation * targetHorizontalMovement;
         currentMovement = targetHorizontalMovement * moveSpeed;

but then my player wouldn't move at all. So then I switched back to my already working code:

 targetRotation += Input.GetAxisRaw ("Rotate") * rotationSpeed * Time.deltaTime;

     if(targetRotation > 360)
         targetRotation -= 360;
     if (targetRotation < 0)
         targetRotation += 360;
     currentRotation = Mathf.SmoothDampAngle (currentRotation, targetRotation, ref rotationV, rotationSpeedSmooth);
     //Rotation code.
     transform.Rotate (0, Input.GetAxisRaw ("Rotate") * rotationSpeed * Time.deltaTime, 0);
     //Smooth rotations.
     transform.eulerAngles = new Vector3 (0,currentRotation ,0);

     //Smooth player movements.
     currentForwardSpeed = Mathf.SmoothDamp(currentForwardSpeed, Input.GetAxisRaw ("Vertical")* moveSpeed, ref forwardSpeedV, moveSpeedSmooth);
     //Movement code.
     currentMovement = new Vector3 (0, currentMovement.y, currentForwardSpeed);
     //Proper movement.
     currentMovement = transform.rotation * currentMovement;  

But that wouldn't work either. I did debug.log on the axis to see if it was responding properly and it was working fine. But the character won't move. He will rotate but not move forward like he used to and I didn't change any of the original code.

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 YoungDeveloper · Jul 28, 2015 at 09:13 PM 0
Share

are you checking for input in Update ?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jdelaay025 · Jul 29, 2015 at 12:28 AM

I actually figured it out after a few minutes. I never called the controller to actually make any actions thus there was no movement. All I did was add

controller.Move(currentMovement * Time.deltaTime);

and the character moves exactly how it is supposed to.

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

Answer by jdelaay025 · Jul 29, 2015 at 12:28 AM

This is so cool that I asked this question so little time ago and it's already being responded to by people. I love the unity community. yes. the input was in the update section

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

how to set up a joystick using input manager for first person controller in unity 4.2.1? 1 Answer

Joystick Input - "3rd Axis" etc, not sure what works/doesn't 1 Answer

Joystick & RotateAround 1 Answer

I cant figure out how to change my simple Movement controls to touch, can anyone help? 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