Perhaps include a section on mapping an X-box controller button

Just a thought but it might be worth including a bit extra on adding the firing control to an X-box controller button to allow firing. I seem to recall that you talked earlier about using an X-box controller joystick to control x/y axis movement (unless I imagined that), so it might be useful to add something on how to map the controller buttons to the Unity input settings. Personally I find a joystick controller much easier to use for navigation than a keyboard (which results in my hands locking into claws if I do it for any length of time :tired_face: ) and being able to use the controller for both movement and firing makes life a bit easier. Of course, you could just suggest it as an exercise and supply a link to the mapping if you wish.

X-box controller map

2 Likes

Re-purposing ‘Fire1’ for ‘Fire’ I was able to have button ‘A’ of an Xbox One controller act as the fire button.

1 Like

Just spent nearly 2 hours trying to get my fire control mapped to the correct button (right trigger) on my XBox360 gamepad. finally found the solution as follows:

Set up the input settings as shown
image

use the following in your code:

        private void Update()
        {
            //Right Trigger
            if (Input.GetAxis("Fire1") >= Mathf.Epsilon)
            {
                print("Firing");
            }

            //Left Trigger
            if (Input.GetAxis("Fire1") <= -Mathf.Epsilon)
            {
                
            }
        }

Note: this script was written for Unity 2019.1.12f1 which has the Cross-Platform Input Manager built into its API.

http://wiki.unity3d.com/index.php/Xbox360Controller

I also found another way of doing this. This code keeps one of the laser particles that are already projected to continue going until they reach their end of life. I did this because if I tried to do it any other way it led to too much garbage collection on the part of the compiler. Here is the code.

For the cross platform input manage be sure to set the type to “Joystick Axis” and Axis is “10th Axis”

Privacy & Terms