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 /
  • Help Room /
avatar image
0
Question by GayPornStudio · May 24, 2016 at 02:48 PM · c#scripting probleminput

Input does't work at all for me

I have am trying this code with default input manager settings. It is attached to a game object with no other components in scene. Its Camera field is setted to default camera in the scene. Each input function returns false/0 no matter what I try. Even Input.anyKeyDown never returns true.

     public class KeyboardController : MonoBehaviour
     {
         public float YMin = -100;
         public float YMax = 100;
         public float XMin = -100;
         public float XMax = -100;
 
         public float XSpeed = 1;
         public float YSpeed = 1;
 
         public float MouseXSpeed = 1;
         public float MouseYSpeed = 1;
 
         public GameObject Camera;
 
         public void Update()
         {
             var pos = Camera.transform.position;
             var x = pos.x;
             var y = pos.y;
 
             if (Input.GetKeyDown(KeyCode.Mouse1))
             {
                 x += MouseXSpeed * Time.deltaTime * Input.GetAxis("Mouse X");
                 y += MouseYSpeed * Time.deltaTime * Input.GetAxis("Mouse Y");
             }
             else
             {
                 x += XSpeed * Time.deltaTime * Input.GetAxis("Horizontal");
                 y += YSpeed * Time.deltaTime * Input.GetAxis("Vertical");
             }
 
             if (x < XMin)
                 x = XMin;
             else if (x > XMax)
                 x = XMax;
 
             if (y < YMin)
                 y = YMin;
             else if (y > YMax)
                 y = YMax;
 
             Camera.transform.position.Set(x, y, pos.z);
         }
     }
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 TBruce · May 25, 2016 at 01:26 AM 1
Share

You should consider changing your account name. Spam filters will block it and moderators who rely on their email to check out questions will never see it.

avatar image Mmmpies · May 26, 2016 at 10:02 AM 1
Share

First thing to do is stick some Debug.Log's in there. It'll instantly show if the issue is not getting input or the rest of the code not working as you expect.

Then consider changing your forum name :D - although it makes me laugh :)

avatar image GayPornStudio Mmmpies · May 26, 2016 at 10:13 AM 0
Share

Actually I tested it with both Debug.Logs and break points, it doesn't print/stop there.

avatar image Mmmpies GayPornStudio · May 26, 2016 at 10:18 AM 1
Share

O$$anonymous$$ what about trying $$anonymous$$eyCode.$$anonymous$$ouse0

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TBruce · May 26, 2016 at 03:39 PM

KeyCode.Mouse1 refers to the secondary mouse button which in most cases is the right mouse button.

But if using Input.GetKeyDown(KeyCode.Mouse0) (left) / Input.GetKeyDown(KeyCode.Mouse1) (right) is not working for you then I would suggest using

 Input.GetButtonDown("Fire1"); (Left)

or

 Input.GetButtonDown("Fire2"); (Right)

Also do you always want to be falling into the else block if mouse is not pressed?

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 GayPornStudio · May 26, 2016 at 03:43 PM 0
Share

Yeah, thx. Anyway I had weird problems with Input cuz of corrupted sytem on dying SSD. It is TBS game with upside down camera, so it's not falling and height is Z there anyway.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Movement Sticking 0 Answers

Issue toggling Particle system on/off using bool. 1 Answer

How to tilt a sprite based on pointer position? 1 Answer

Getting mouse input in screen (0,0) and drag mouse 0 Answers

No input coming from using new input system, and variable not viewed in inspector. 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