Me and friend are trying to figure out how to get a callback context from a Game Object using a Player Input component to get the device of the button that has been pressed, if it’s possible?
Basically I’m trying to get some multiplayer functionality going. When I press a face button, I need to get which controller pressed said button and return the device. This is what we tried so far:
void MyButtonPress(InputAction.CallbackContext ctx)
{
InputDevice device = ctx.control.device;
Debug.Log(device);
}
This is what my friend came up with, but I wanted to do this within the method called by the Player Input (MyButtonPress, in the example above)
void Awake()
{
ctrl.Ctrl.Act.performed += ctx => onButtonPress(ctx);
}
void onButtonPress(InputAction.CallbackContext ctx)
{
InputDevice device = ctx.control.device;
Debug.Log(device);
}