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 Username6895 · Aug 30, 2015 at 09:14 PM · unity 5camerainputinputmanager

ArgumentException: Input Axis MousePan is not setup.

Hello! I've recently found an excellent unity 5 RTS camera tutorial.

I've been following the steps and i've completed the C# script, however upon running the scene i'm prompted with this error:

ArgumentException: Input Axis MousePan is not setup. To change the input settings use: Edit -> Project Settings -> Input RTSCamera.GetInput () (at Assets/RTSCamera.cs:61) RTSCamera.Update () (at Assets/RTSCamera.cs:71)

Now, I look at the Project Settings > Input and Axis MousePan is not there.

Any ideas?

Posting the code below encase it is needed.

 using UnityEngine;
 using System.Collections;
 
 public class RTSCamera : MonoBehaviour {
 
     public LayerMask groundLayer;
 
     [System.Serializable]
     public class PositionSettings
     {
         public bool invertPan = true; //Pans screen when cursor hits screen border
         public float panSmooth = 7f;
         public float distanceFromGround = 40;
         public bool allowZoom = true;
         public float zoomSmooth = 5;
         public float zoomStep = 5;
         public float maxZoom = 25;
         public float minZoom = 80;
     
         [HideInInspector]
         public float newDistance = 40; 
     }
 
     [System.Serializable]
     public class OrbitSettings
     {
         public float xRotation =50;
         public float yRotation =0;
         public bool allowYOrbit = true;
         public float yOrbitSmooth = 0.5f;
     }
 
     [System.Serializable]
     public class InputSettings
     {
         public string PAN = "MousePan";
         public string ORBIT_Y = "MouseTurn";
         public string ZOOM = "Mouse ScrollWheel";
     }
 
     public PositionSettings position = new PositionSettings();
     public OrbitSettings orbit = new OrbitSettings();
     public InputSettings input = new InputSettings();
 
     Vector3 destination = Vector3.zero;
     Vector3 camVel = Vector3.zero;
     Vector3 previousMousePos = Vector3.zero;
     Vector3 currentMousePos = Vector3.zero;
     float panInput, orbitInput, zoomInput;
     int panDirection = 0; 
 
     void Start() //
     {
         panInput = 0;
         orbitInput = 0;
         zoomInput = 0;
     }
 
     void GetInput() //
     {
         panInput = Input.GetAxis (input.PAN);
         orbitInput = Input.GetAxis (input.ORBIT_Y);
         zoomInput = Input.GetAxis (input.ZOOM);
 
         previousMousePos = currentMousePos;
         currentMousePos = Input.mousePosition;
     }
 
     void Update() //
     {
         GetInput();
         if (position.allowZoom)
             Zoom();
         if (orbit.allowYOrbit)
             Rotate();
         PanWorld();
     }
 
     void FixedUpdate() //
     {
         HandleCameraDistance();
     }
 
     void PanWorld() //
     {
         Vector3 targetPos = transform.position;
 
         if (position.invertPan)
             panDirection = -1;
         else
             panDirection = 1;
 
         if (panInput > 0) 
         {
             targetPos += transform.right * (currentMousePos.x - previousMousePos.x) * position.panSmooth * panDirection * Time.deltaTime;
             targetPos += Vector3.Cross(transform.right, Vector3.up) * (currentMousePos.y - previousMousePos.y) * position.panSmooth * panDirection * Time.deltaTime;
         }
         transform.position = targetPos; 
     }
 
     void HandleCameraDistance() //
     {
         Ray ray = new Ray(transform.position, transform.forward);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 100, groundLayer))
         {
             destination = Vector3.Normalize(transform.position - hit.point) * position.distanceFromGround;
             destination += hit.point;
 
             transform.position = Vector3.SmoothDamp(transform.position, destination, ref camVel, 0.3f);
         }
     }
 
     void Zoom() //
     {
         position.newDistance += position.zoomStep * zoomInput;
 
         position.distanceFromGround = Mathf.Lerp (position.distanceFromGround, position.newDistance, position.zoomSmooth * Time.deltaTime);
 
         if (position.distanceFromGround < position.maxZoom) 
         {
             position.distanceFromGround = position.maxZoom;
             position.newDistance = position.maxZoom;
         }
         if (position.distanceFromGround > position.minZoom)
         {
             position.distanceFromGround = position.minZoom;
             position.newDistance = position.minZoom;
         }
     }
 
     void Rotate() //
     {
         if (orbitInput > 0) 
         {
             orbit.yRotation += (currentMousePos.x - previousMousePos.x) * orbit.yOrbitSmooth * Time.deltaTime;
         }
 
         transform.rotation = Quaternion.Euler(orbit.xRotation, orbit.yRotation, 0);
     }
 
 }

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 itsharshdeep · Aug 31, 2015 at 05:05 AM 0
Share

You have to create the new axis names "$$anonymous$$ousePan", "$$anonymous$$ouseTurn" & "$$anonymous$$ouse ScrollWheel".

but I dont know what properties should be. You have to check this from there where you get this code . (If you copied the code from somewhere else).

avatar image sr3d · Oct 23, 2015 at 01:20 PM 0
Share

Did anyone figure this out?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unclerunning · Nov 27, 2015 at 11:17 AM

Either you have to create the new axis names "MousePan", "MouseTurn" & "Mouse ScrollWheel" or you have to change this name to match what you have in your Input setting such as "Horizontal","Vertical". this problem happens when you use a name in your script but it doesn't exist in the Edit -> Project Settings -> Input.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

New Input system not serialized? 1 Answer

Getting Joystick Input from Matricom G-Pad BX? 0 Answers

Unity hot plug-in with controller 0 Answers

Unity's 2D Gamekit Input problem 1 Answer

UI buttons not working with Unity new input system 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