Controller Sensor Stick to calculator (Bug?)
I came about a strange issue yesterday, and I wanted to know if it's a bug or if I'm misunderstanding a gadget.
I wanted an event to trigger when the player tilts the left stick fully in any direction, so I connected the fat wire output of the left stick of the controller sensor to a calculator A input, set B to 0.95 (including a bit of tolerance) and switched to "Greater Than". Result: A always shows a value equal or above 1 if the stick is fully tilted, but the calculator does not always put out a "true" value. Turns out the calculator behaves just like it does if the fat wire is split into X and Y axis and then both wires get connected to the A input (and in that case, the A value and "true" output makes sense). Same goes for Right Stick and local sticks.
So I guess I can't use the calculator to trigger something when the stick is tilted to a certain amount. In my specific case I can easily work around that, but I didn't find any information about this issue, so I wanted to discuss it here and if it's a bug, I hope it gets fixed.
-
The "sticks" fat wire type that you get from the Controller Sensor's left stick output is one of the fat wire types that the Calculator handles as a vector, even when the other input is a scalar.
In your case, when you push the stick in a direction that corresponds to scene space positive X or scene space positive Z (or right or down when you're using one of the "local sticks" outputs), you get the vector [1.0, 0.0] or [0.0, 1.0]. When a calculator compares that to the scalar 0.95 using operation >, it outputs the vector [1.0, 0.0] or [0.0, 1.0], and when that vector is received by something that expects a scalar, it's converted to the vector's magnitude, which is 1.0 - a true value.
But when you push the stick in a different direction - say, a diagonal - you get a vector like [0.707, 0.707], and when the Calculator compares that to the scalar 0.95 with the operation >, it outputs the vector [0.0, 0.0], and when that vector is received by something that expects a scalar, it's converted to the vector's magnitude, which is 0.0 - a false value.
You want the > 0.95 comparison to be comparing with the magnitude of the vector, not the individual vector components, and you can do this by setting the A input of the calculator to 1.0 and setting the input's blend mode to modulate. That forces the Calculator's A input to convert the vector to a scalar before performing the comparison, and you should get the results that you were expecting - a true value when the stick is fully tilted.
-
(nods at BeardyMan)
No bug, it's working as designed. I have tutorials on their way about how this stuff works, but they're on patreon.com/tapgiles only right now.
-
Thanks for your replies everyone!
@TheBeardyMan I can't say that I fully understood the issue, but I used your suggestion in my creation.Guess you can connect stuff the "wrong" way if vectors and scalar input/output collide? Sounds like an intersting theme to learn more about.
請登入寫評論。