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 Graeme P · Apr 19, 2011 at 03:43 PM · inputcontrollerxbox360

Please help me set up my inputs. Im pretty confused.

if (Input.GetAxis("Vertical"))

{ transform.position += transform.forward moveSpeed Time.deltaTime;

}

 if (Input.GetAxis("Vertical"))

{ transform.position += -transform.forward moveSpeed Time.deltaTime;

}

 if (Input.GetAxis("Horizontal"))

{ transform.eulerAngles.y += - turnSpeed * Time.deltaTime;

}

 if (Input.GetButton("Horizontal"))

{ transform.eulerAngles.y += turnSpeed * Time.deltaTime;

} }

How do i define which are positive and which are negative? - Do i have to set up two inputs per axis, i know this is probably a silly question (i apoagies.) but im really struggling to find an appropriate solution.

Also, is there an easy way of setting it up detect the amount of force on the stick?

I would really appreciate your help - as always.

Thanks,

  • Graeme.

Comment
Add comment · Show 1
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 Graeme P · Apr 19, 2011 at 03:44 PM 0
Share

that last getbutton is ment to be axis too, just forgot to change it.

2 Replies

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

Answer by FLASHDENMARK · Apr 19, 2011 at 04:41 PM

I am not a 100% sure on what you are trying to achive but anyways:

function Update () { var horizontalSpeed = Input.GetAxis("Horizontal");

var verticalSpeed = Input.GetAxis("Vertical");

transform.position += transform.forward verticalSpeed Time.deltaTime;

transform.positon += transform.right horizontalSpeed Time.deltaTime; }

You only need to use 1 axis at the time. Since Input.GetAxis returns form -1 to 1 and therefor it is unneccersary to use this twice:

if (Input.GetAxis("Vertical"))
{      
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}   
if (Input.GetAxis("Vertical"))
{      
transform.position += -transform.forward * moveSpeed * Time.deltaTime;
}

but simply use:

var verticalSpeed = Input.GetAxis("Vertical");

transform.position += transform.forward verticalSpeed Time.deltaTime;

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 Graeme P · Apr 19, 2011 at 09:35 PM 0
Share

Thank you for your help, exactly what I needed! =) - I really appreciate you guys sharing your knowledge.

avatar image
2

Answer by Muzz 1 · Apr 19, 2011 at 03:57 PM

You don't actually need two seperate ones. Just use one for each! Horizontal means both left and right, with one (I think left, but check this) being negative and the other positive. Same with Vertical --- it accounts for both. So just lose some of the excess statements, and it'll be fine.

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

No one has followed this question yet.

Related Questions

different behaviour of axis using xbox360 controller 1 Answer

Multiple x360 controllers get wrong IDs assigned. 2 Answers

GetButtonDown not responding to Xbox 360 Button presses 0 Answers

Remote user game pads stuck on X axis, locally fine. 1 Answer

360 Trigger Pressing both Triggers at the same time 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