[SOLVED] Using joystick

I am trying to make it so that when I complete my game I will try to play the game on my Nintendo Switch, but I cannot figure out how to do the controller joystick inputs. I looked for a while, and I cannot figure it out, can I have some help on how to do it

my game is a 3D first person game, so I need the right joystick to rotate the camera, and the left joystick to move the player, I already have the other things set up

@Linkplayer I am not sure how you have your code written but you will have to enable gamepad I think in your settings.

Here is a link to some documentation:

I followed what it says and messed around with it and nothing worked, I tried things like:
This.app.gamepad.getAxis()
This.app.gamepad.axis.getAxis()
This.app.gamepad.getAxis(PAD_L_STICK_X)

None of it worked

@Linkplayer The web browser built into the switch may be an issue.

I think the above may offer some answers. If you have a computer that you are developing on is it possible that you also have a gamepad type controller for your PC. If so do you get the same reaction?

@Tirk182 makes a good point, I’m not fully sure if the switch browser supports that.

@Linkplayer can you try checking your connected gamepad on this site and see if it responds as expected?

https://hardwaretester.com/gamepad

2 Likes

I don’t even have the ability to code it to be joystick-compatible yet, I am trying to figure that out right now, I know how I can upload my game to the switch, but if I did right now, I would be unable to move

@Linkplayer I admire your excitement about running a Playcanvas game on the switch. Let me try to explain some of the aspects that you are working with. Playcanvas is a really great platform for game development. It is however based on web browser usage. What makes this great is that you can develop a game on your PC and share it with a large user base since technically any device that has a full browser interface whether it is a cell phone, tablet, PC, Mac, etc it will run. There is however a way the you can make your game stand alone by using Electron. Electron emulates a browser on a device so it will act as stand alone.

The Nintendo Switch is somewhat of a closed system. You must sign a NDA with Nintendo International and supply a description of the game you plan on designing for their approval. There is a special SDK which includes a version of Unity that enables developers to download and debug directly on the Switch. The Switch itself uses a special file format that was developed by Nintendo. To the best of my knowledge you can not download a file directly to the switch and have it run your application.

Please see this link for more information. This is the process I am currently going through and awaiting Nintendo Internationals response.

https://developer.nintendo.com/the-process

I follow @Leonidas suggestion first by using the Gamepad Tester. Also, this Playcanvas game has some history but will give you a test game for testing gamepads. You can fork it and try out a gamepad of your choice on a PC or Mac or Chrome device that supports either a Bluetooth or wired controller. Using the tester program to make sure your device is recognized.

https://playcanvas.com/project/331628/overview/zombie-pacman

I hope this helps you and please feel free to ask more questions.

2 Likes

I basically already know that. I know someone who knows how to transfer the code to be switch compatible, but the switch can also get games from microSD cards, which you can put into the console, but my biggest question still remains, how do you code the usage of joysticks, or anything with gamepads in general, I cannot figure any of them out.

@Linkplayer Do you have a PC or a development environment that you can test the gamepad controllers? If so have you tried the project link provided above? One way to get to know your switch controller is to Bluetooth connect the controller to a PC/Mac/Maybe Chrome device and use the above test program as pointed out by @Leonidas.

If you have a project that you can share the link of with the forum that would be great for all of us to help. It would be very helpful to know why a gamepad is not working formulate an answer. It’s very hard to understand why it isn’t working without debugging it a bit.

As for the Switch download and execution, the statement above covers the extent of my knowledge. Sounds like you have the execution of a browser based system covered.

I copied this from another post.
I’m running from memory here:

  1. In the project settings in the editor, there should be a tickbox called ‘use gamepads’ or similar. This will initialise the gamepad code at startup.
  2. You can then access the connected gamepads from this.app.gamepads from any pc.script.
  3. From there, you can use the API docs to get the current state of each connected gamepad https://api.playcanvas.com/classes/Engine.GamePads.html

To get the access IDs and/or button IDs, use this tester https://html5gamepad.com/

A good search of the forum is here:
https://forum.playcanvas.com/search?q=gamepad%20use

As I read you response closer I also see the following error
This.app.gamepad.getAxis()
This.app.gamepad.axis.getAxis()
This.app.gamepad.getAxis(PAD_L_STICK_X)

This …>>>>>> should be this.app.gamepad lower case on this

I will try that, and for the controller for the testing, I have switched USB plugins that I could test out the script with.

also the capital in This was because of auto correct on my computer, because it thought the word → (this) was the first word in the sentence

nvm I did not know that gamepad is a pc type script, not an app type script I figured it out

now how do I say this question is solved

Hi @Linkplayer!

You can edit your title and if this is not possible a moderator will do it for you, like I have done right now.