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 darthbator · Oct 10, 2013 at 05:54 AM · ps3sixaxis

Six Axis support in Unity

Is there any way to enable sixaxis support for PS3 controllers on PC in Unity. Either via plugin or native support. I've googled around a little bit and didn't find anything (I could also have done an insufficient job). Thanks!

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
0

Answer by LoganPark · Oct 23, 2013 at 03:17 AM

On OSX, at least, it seems to plug in and work fine, and wirelessly as well. I used the following basic script (csharp, but a JS port would be easy) to map out the buttons. Put this code block into void OnGUI()...

 GUI.Label( new Rect(20,20,400,20), "Active Joystick: " + Input.GetJoystickNames()[0] + ".");
 
 float yOffset = 40.0f;
 int buttonIndex = 0;
 
 if(Input.GetKey(KeyCode.JoystickButton0)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Select");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Select");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton1)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Joystick Press");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Joystick Press");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton2)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Joystick Press");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Joystick Press");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton3)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Start");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Start");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton4)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Up");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Up");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton5)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Right");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Right");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton6)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Down");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Down");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton7)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Left");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Left");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton8)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Trigger");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Trigger");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton9)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Trigger");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Trigger");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton10)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Bumper");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Bumper");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton11)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Bumper");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Bumper");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton12)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Green / Triangle / Upward");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Green / Triangle / Upward");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton13)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Red / Circle / Rightward");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Red / Circle / Rightward");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton14)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Blue / X / Downward");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Blue / X / Downward");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 if(Input.GetKey(KeyCode.JoystickButton15)) {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Pink / Square / Leftward");
 } else {
     GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Pink / Square / Leftward");
 }
 yOffset += 20.0f;
 buttonIndex++;
 
 GUI.Label (new Rect (20, yOffset, 500, 20), "Left Thumbstick: " + Input.GetAxis("L_XAxis_0").ToString("f1") + "," + Input.GetAxis("L_YAxis_0").ToString("f1"));
 yOffset += 20.0f;
 GUI.Label (new Rect (20, yOffset, 500, 20), "Rite Thumbstick: " + Input.GetAxis("R_XAxis_0").ToString("f1") + "," + Input.GetAxis("R_YAxis_0").ToString("f1"));
 } // End Playstation 3 controller

Very best of luck to you. Note that you would need to define L_YAxis_0 and L_YAxis_0 and L_XAxis_0 and R_XAxis_0 in the Edit --> Project Settings --> Input editor (Joystick axes).

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

16 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

Related Questions

Xbox 360 Developing 2 Answers

Multiple controller buttons Xbox 360 & PS3 different controllers 1 Answer

Unity to PS3 or 360 2 Answers

PS3 controller, bluetooth and Unity. 0 Answers

Will it be possible to develop for the PSP vita? 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