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 vadrian0 · May 27, 2018 at 02:32 PM · joystickcharacter controllercamera rotate

Joystick to movement and rotate camera same time

Hello,

I have a problem. I want to use joystick to movement player. I want to rotate camera if player click ANYWHERE ELSE on screen.

alt text

My problem: If the player use joystick then camera rotate too! I tried IsPointerOverGameObject not good, because player press the joystick and drag it to the screen then joystick still work, but camera rotate again :( So I think if player use joystick then I disable rotate camera, but not good, because If player use two fingers it is possible both at the same time. (one finger joystick and one finger screen)

     public float speed = 2.0f;
     private float X;
     private float Y;
 
 
 
     void Update() {
 
         if (Input.GetMouseButton (0)) {
     
         
             if(!EventSystem.current.IsPointerOverGameObject ())  {
 
 
                     transform.Rotate (new Vector3 (Input.GetAxis ("Mouse Y") * speed, -Input.GetAxis ("Mouse X") * speed, 0));
                     X = transform.rotation.eulerAngles.x;
                     Y = transform.rotation.eulerAngles.y;
                     transform.rotation = Quaternion.Euler (X, Y, 0);
                 }
             
             }
 
         }

So another solution is needed. If player use the joystick, do not move the camera. But if player use it with two fingers (one with the joystick and the other with the camera allowed!) I hope you understand. (similar to other shooting games).

Thanks!

Comment
Add comment · Show 2
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 JxWolfe · Apr 09, 2020 at 07:21 PM 0
Share

personally, why bother with the mouse? I'd map a joystick key. You are also alittle confusing (sorry). What's with the mouse having to be over a gameobject?

if(mouse down) { camera.Rotate (new Vector3 (Input.GetAxis ("$$anonymous$$ouse Y") * speed, -Input.GetAxis ("$$anonymous$$ouse X") * speed, 0)); } if(joystick value != 0) { move player }

avatar image JxWolfe · Apr 09, 2020 at 07:22 PM 0
Share

so breaking that down. if the mouse is being held down, roate the camera. then regardless of weither or not the mouse is being held, if the joystick is active then move the player

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NatalieW15 · Apr 09, 2020 at 07:08 PM

Did you find the answer?

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

86 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

Related Questions

Character controller Joystick issues. 1 Answer

Limit Vertical (Y Position) of Player Camera on Joysticks? 0 Answers

How do I get this to Rotate properly? 1 Answer

How can I use a joystick for a mobile app to control specific limbs of a character? 0 Answers

If Statement Triggers No Matter What! 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