Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Penfwasaurus · Nov 01, 2013 at 12:38 PM · c#javascriptaxisgetbutton

'Getbutton' Or 'GetAxis' Not working at all!

I started making a fantasy game, and when it came to melee, I used the code (in Js) 'if ( Input.GetAxis("Fire1")) Which I know should work perfectly, But my Axis buttons dont work at all! Then I tried to Make an fps, (c#) and when i typed in the code 'Input.GetAxis("Vertical"); It doesnt work at All! I dont know whats happened to my axis buttons but I cant make ANY game because they dont work/respond, i've also researched all the right settings too in project settings > Input.

Unitys's pointless until my axis buttons Work!

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 mattssonon · Nov 01, 2013 at 12:58 PM 0
Share

Try Input.GetButton("Fire1") not Input.GetAxis("Fire1").

avatar image Penfwasaurus · Nov 01, 2013 at 07:38 PM 0
Share

I didnt mean it like that, I meant that Anything I put 'Fire1' 'Vertical' 'horizontal' It never works, but the scripts fine. Its as if the actual inputs just dont work

avatar image Bloodyem · Nov 02, 2013 at 06:31 PM 0
Share

Have you checked the input? It says you researched them, have you tried doing something like:

 var vertical : float;
 var horizontal : float;
 
 function Update () {
 vertical = Input.GetAxis("Vertical");
 horizontal = Input.GetAxis("Horizontal");
 }

That's how I use my axis keys.

avatar image Freaking-Pingo · Nov 02, 2013 at 07:06 PM 0
Share

This question is rather difficult to debug without any further information, but a few tips you could try.

  • I presume you are using $$anonymous$$onobehaviour methods such as void Start(), void Awake() or even void Update(). If so, have you made sure your script is attached to a GameObject on the scene?

  • Try using Debug.Log("Something") before and after your I`nput.GetAxis("Vertical");` to see if the code is actually being executed.

avatar image TalkingDog · Jan 09, 2014 at 09:11 PM 0
Share

I'm also having an issue where I'm not getting any values for GetAxis("Vertical"); or likewise for horizontal

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sanchay · Dec 26, 2014 at 10:50 PM

Try this

using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour {

 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");

     Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
     rigidbody.AddForce(movement);
     }

}

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

20 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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Convert C# Into UnityScript - Events in Unityscript 2 Answers

Unity v4.6 Joystick? 2 Answers

Application.ExternalCall Issue 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