Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 InsaneStudio · Apr 22, 2017 at 07:58 PM · camera rotate

Rotate Camera using a joystick or buttons

Hello Everyone, I've been struggling with this problem, I have a working FPS Camera script attached to a camera and capsule I want to transfer it to a joystick or buttons this is my script :

         using UnityEngine;
         using System.Collections;
         
         [AddComponentMenu("Camera-Control/Mouse Look")]
         public class MouseLook : MonoBehaviour
         {
         
             public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
             public RotationAxes axes = RotationAxes.MouseXAndY;
             public float sensitivityX = 15F;
             public float sensitivityY = 15F;
         
             public float minimumX = -360F;
             public float maximumX = 360F;
         
             public float minimumY = -60F;
             public float maximumY = 60F;
         
             float rotationY = 0F;
         
             void update()
             {
                 if (axes == RotationAxes.MouseXAndY)
                 {
                     float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
         
                     rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                     rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
         
                     transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
                 }
                 else if (axes == RotationAxes.MouseX)
                 {
                     transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
                 }
                 else
                 {
                     rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                     rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
         
                     transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
                 }
             }
         }
     
 I already have Left Right Up Down buttons in a Canvas how can I transfer the script so I can rotate it with buttons

thank you so much

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
1
Best Answer

Answer by Namey5 · Apr 24, 2017 at 10:41 AM

In the inspector, go to Edit>Project Settings>Input. This should open the input manager. From here, increase the amount of inputs to however many more you require. Then, for each of these new inputs, rename them to the inputs used (i.e. "Mouse X", "Mouse Y"). Then, configure these inputs to use different buttons/axis'. As long as they have the same name, Unity will automatically search for input from all of these at once.

At the bottom of the following link are the general names and such that you can set;

https://docs.unity3d.com/Manual/ConventionalGameInput.html

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 InsaneStudio · Apr 28, 2017 at 12:11 AM 0
Share

Thank you so much, I found a solution using Easy Touch from the asset store

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

100 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

Related Questions

How to change settings OnTrigger 1 Answer

When attaching my custom camera script camera shakes when player starts to move fast. 1 Answer

Camera spawn rotate with object 0 Answers

How to detect how much was mouse moved only horizontaly? 1 Answer

How do I clamp this camera rotation? 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