PlayMaker Help & Tips > PlayMaker Tips & Tricks

Solution for the XBOX 360/One Controller Trigger Input

(1/3) > >>

Chris Vitorino:
I've been struggling with this logic problem for 17 hours now in total. Finally got to solve it after intensive research.

When I needed this community to help me, it did it in a blink, time to give back some love : )

So, if you're using playMaker, and the XBOX 360/One Controller is the main input device for your game, and you're wondering why you can't get the Triggers to work, this is for you.

Microsoft made the Triggers to be sensible, therefore, they're Axis, not Buttons, in order to allow acceleration.

The problem: Even though you can get the Axis, how do you solve the acceleration? Why it starts in a already fired state?

The solution: The Axis range are -1 to 1. So why? Here lies the problem - The triggers are parked at 0 by default. From here, you can work your way to the solution, the images should be enough for a clear explanation of the logic. Notes included.







Special Thanks
Alex Chouls - For confirming what I was suspicious about the loop problem - http://hutonggames.com/playmakerforum/index.php?topic=6511.msg31804#msg31804
slog - for pointing out the problem of the 0 start state - http://answers.unity3d.com/questions/434129/mac-xbox-controller-detect-trigger-input.html

Other topics with the same problem
http://hutonggames.com/playmakerforum/index.php?topic=10971.0
http://hutonggames.com/playmakerforum/index.php?topic=10519.0
http://hutonggames.com/playmakerforum/index.php?topic=10354.0

djaydino:
hi,
thx for the tip, but the pictures can't be seen :)
can you upload them somewhere (not in your dropbox) and reconnect them?

Chris Vitorino:

--- Quote from: djaydino on August 21, 2015, 02:53:34 AM ---hi,
thx for the tip, but the pictures can't be seen :)
can you upload them somewhere (not in your dropbox) and reconnect them?

--- End quote ---

Thank you for the heads up. I forgot that OS X makes TIFFs by default, my bad. The PNGs from imgur should be working now.

foxdeltagames:
So in other words, to make the trigger buttons to work. 0 on the trigger axis means its inactive, but for example to fire a weapon tell playmaker to detect 1 on the axis that the trigger is on, that should allow you to fire your weapon. untill you let go of the trigger and go back to 0 on the axis, and that will stop that fore action.

Chris Vitorino:

--- Quote from: foxdeltagames on September 12, 2015, 06:07:14 PM ---So in other words, to make the trigger buttons to work. 0 on the trigger axis means its inactive, but for example to fire a weapon tell playmaker to detect 1 on the axis that the trigger is on, that should allow you to fire your weapon. untill you let go of the trigger and go back to 0 on the axis, and that will stop that fore action.

--- End quote ---

Almost. It never goes to 0 again. On the moment you start pressing the trigger, it will become the range -1 to 1. Just like a car's accelerator pedal.

As you press for the first time, and keep pressing further, it will start the linear progression of the axis, -1, -0.9, -0.8... until it reaches 1.

In your example, once you release the trigger after shooting your weapon, the trigger will decrease its axis from 1 to 0.9, 0.8... going through 0, until you fully release the trigger and it rests at -1.

You can link an action to any of these values if you want, for example, so the weapon only shoots a bit late but not so late, let's say, at 0.3. Or implement an acceleration action, like stretching a bow string to shoot an arrow for example, and depending of the stretching strength, a different damage is applied.

It's a very odd behavior, it should start at the range, but it starts at 0 instead, to never go to 0 again once pressed for the first time, unless you quit Unity or the Game.

You can use the Controller Tester asset from the asset store to observe this behavior, it's free.

If you think this is a bit complicated, wait until you have to work with the Steam Controller, which has it's triggers working as an axis and buttons at the SAME TIME. I hope the behavior is separated, and not hardcoded into a single bahavior.

My guess is that it will have a "click" virtual (or maybe physical) button at the end of each range, working as a real button, to separate itself from the accelerating range behavior. If my guess is somewhat correct, then it will not be so complicated at all.

Navigation

[0] Message Index

[#] Next page

Go to full version