playMaker

Author Topic: InControl Custom Actions  (Read 9818 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: InControl Custom Actions
« Reply #15 on: May 12, 2015, 01:53:08 AM »
Hi,

 ok, I have created a rep for this, and the new package to support this version is on the wiki:

https://hutonggames.fogbugz.com/default.asp?W1183

 Let me know how it goes.

 Bye,

 Jean

aceofclubs

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: InControl Custom Actions
« Reply #16 on: May 13, 2015, 09:25:50 AM »
Thanks for this,

Added the actions in and it does not bomb the program anymore.  Defiantly a bonus.

I am currently working to try to extend the actions/create new ones so it will also look for the TouchManager class/Devices since the current actions appear to be ignoring touch input controllers.

TouchManager
http://www.gallantgames.com/incontrol-api/html/class_in_control_1_1_touch_manager.html

TouchSwipeControl
http://www.gallantgames.com/incontrol-api/html/class_in_control_1_1_touch_swipe_control.html



AoC

aceofclubs

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: InControl Custom Actions
« Reply #17 on: May 13, 2015, 11:47:25 AM »
TouchManager Controls:

So far I have been unable to get Playmaker to register the TouchSwipeControl Button Presses with out adding  "inputDevice = InputManager.ActiveDevice;"  to the onUpdate() function

I created a separate action below to handle the Swipe commands, however I am positive it will break if you are trying to use more then 1 controller per device as well.

It does not restrict the "Controller" input.  So for example:  anything that reports D Pad Up was pressed will fire off the code below if your ControlCommand is D Pad Up.


Code: [Select]
using UnityEngine;
using InControl;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory("InControl")]
    [Tooltip("Sends an Event when the specified Incontrol control Axis. Optionally store the control state in a bool variable.")]
    public class GetSwipeButtonControls : FsmStateAction
    {

    public InputControlType ControlCommand;

    public FsmEvent sendEvent;
    [UIHint(UIHint.Variable)]
    public FsmBool storeResult;


    bool wasPressed;
    //bool isDownFlag;

    InputDevice inputDevice;

    public override void Reset()
    {
            inputDevice = InputManager.ActiveDevice;
            ControlCommand = InputControlType.DPadUp;
        sendEvent = null;
        storeResult = null;
    }

    public override void OnEnter()
    {
            inputDevice = InputManager.ActiveDevice;
    }

    public override void OnUpdate()
    {
            inputDevice = InputManager.ActiveDevice;
            var temp = inputDevice.GetControl(ControlCommand).WasPressed;
        //wasPressed = _inputDevice.GetControl(axis).WasPressed;

        if (temp)
        {
            Fsm.Event(sendEvent);

        }

        storeResult.Value = temp;
    }
}
}



AoC

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: InControl Custom Actions
« Reply #18 on: May 13, 2015, 11:09:06 PM »
Hi,

 You should study examples provided by InControl, I haven't digged into the new features. I have to move on other packages to update them.

 Tell me if you still struggle with this, I'll try to have another look. I am very confused with the new set of controls myself tbh, so contacing the author to get clarifications on use case may be necessary, please do if you are stuck, it may be simple.


Bye,

 Jean

aceofclubs

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: InControl Custom Actions
« Reply #19 on: May 14, 2015, 09:45:06 AM »
Here is the Action I am using to use the Swipe Control and a Button control, Both set to take up 100% of the screen.  This gives you the ability to handle Swipes and taps on the same screen.  Be sure to adjust your swipe sensitivity to taste to prevent the swipe control from "eating" all the interactions.

One note the action will not limit itself to the touch controls.  Any control that is being used that is firing off the Button Targets you select will trigger this action.  So for example if you hook up a controller and press D Pad Up it will fire off the swipe up control.  You can change this by inspecting the active device to see if it is the touch manager.  I figured if someone is using the touch controls then they likely are not playing with a second person using a gamepad.

Code: [Select]

using UnityEngine;
using InControl;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory("InControl")]
    [Tooltip("Requires Button and Swipe Control Sends an Event when the specified Incontrol Button Target.")]

    public class SwipeAndTapControlForIncontrol : FsmStateAction
{
        [Tooltip("Touch Button Control Target")]
    public InputControlType ControlCommandTap;
        [Tooltip("Touch Swipe Control Button Target Up")]
    public InputControlType ControlCommandUp;
        [Tooltip("Touch Swipe Control Button Target Down")]
    public InputControlType ControlCommandDown;
        [Tooltip("Touch Swipe Control Button Target Left")]
    public InputControlType ControlCommandLeft;
        [Tooltip("Touch Swipe Control Button Target Right")]
    public InputControlType ControlCommandRight;
        [Tooltip("Event To Send For Tap")]
    public FsmEvent sendEventTap;
        [Tooltip("Event To Send For Up")]
    public FsmEvent sendEventUp;
        [Tooltip("Event To Send For Down")]
    public FsmEvent sendEventDown;
        [Tooltip("Event To Send For Left")]
    public FsmEvent sendEventLeft;
        [Tooltip("Event To Send For Right")]
    public FsmEvent sendEventRight;





    InputDevice inputDevice;

    public override void Reset()
    {
        inputDevice = InputManager.ActiveDevice;
        ControlCommandTap = InputControlType.Action1;
        ControlCommandUp = InputControlType.DPadUp;
        ControlCommandDown = InputControlType.DPadDown;
        ControlCommandLeft = InputControlType.DPadLeft;
        ControlCommandRight = InputControlType.DPadRight;
        sendEventTap = null;
        sendEventUp = null;
        sendEventDown = null;
        sendEventLeft = null;
        sendEventRight = null;

    }

    public override void OnEnter()
    {
        inputDevice = InputManager.ActiveDevice;
    }

    public override void OnUpdate()
    {
        inputDevice = InputManager.ActiveDevice;
        //var temp = inputDevice.GetControl(ControlCommandTap).WasPressed;
        //wasPressed = _inputDevice.GetControl(axis).WasPressed;
        bool wasSwipeRecieved = false;

       

        if (inputDevice.GetControl(ControlCommandUp).WasPressed)
        {
            wasSwipeRecieved = true;
            Fsm.Event(sendEventUp);
        }
        else if (inputDevice.GetControl(ControlCommandDown).WasPressed)
        {
            wasSwipeRecieved = true;
            Fsm.Event(sendEventDown);
        }
        else if (inputDevice.GetControl(ControlCommandLeft).WasPressed)
        {
            wasSwipeRecieved = true;
            Fsm.Event(sendEventLeft);
        }
        else if (inputDevice.GetControl(ControlCommandRight).WasPressed)
        {
            wasSwipeRecieved = true;
            Fsm.Event(sendEventRight);
        }

        else if (inputDevice.GetControl(ControlCommandTap).WasReleased && wasSwipeRecieved == false)
        {

            Fsm.Event(sendEventTap);
        }
       

    }
}
}



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: InControl Custom Actions
« Reply #20 on: May 20, 2015, 01:04:12 AM »
Hi,

 You should either fork the inControl rep or simply use Snipt and share your work on the Ecosystem.

 Let me know if you need some guidance for either.

 Bye,

 Jean

3noneTwo

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: InControl Custom Actions
« Reply #21 on: July 07, 2015, 10:39:50 AM »
Hi Jean,

I've been trying to get PlayMaker and InControl to talk all evening, but no matter what I try, the actions refuse to work.

I can get PlayMaker to update variables using the "Get Axis" action using either keyboard or a controller, and PlayMaker responds to mouse actions as well. Likewise, InControl's example projects work correctly with all types of input. But unfortunately, none of the InControl Custom Actions are functioning for me. No button events, no axis updates, nothing.


Right, I feel rather silly. InControl requires the user to add the "InControl Manager" to the scene before anything starts working. This is also true for InControl Custom Actions, they don't function unless the Manager is in the scene. I wasn't seeing any errors, so I assumed everything was set up correctly.

Newbie mistake, sorry about that!
« Last Edit: July 08, 2015, 04:47:46 AM by 3noneTwo »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: InControl Custom Actions
« Reply #22 on: July 08, 2015, 05:05:08 AM »
:)

no worries, we all get this!

Bye,

 Jean

terri

  • Sr. Member
  • ****
  • Posts: 349
    • View Profile
    • terrivellmann.tumblr.com
Re: InControl Custom Actions
« Reply #23 on: July 08, 2015, 06:24:20 AM »
How are you guys setting up the axis?
It seems like it should have a Left Stick X and Left Stick Y option, but it only has Up/Down/Left/Right.
The way I have it set up like the attached image makes the character only move up and to the right. I seem to be missing something obvious?

edit:
I got it to work by changing these 2 lines on the GetInControlDeviceInputAxisVector action (122,123):

Code: [Select]
var h = _inputDevice.GetControl(horizontalAxis).Value;
var v = _inputDevice.GetControl(verticalAxis).Value;
to
Code: [Select]
var h = _inputDevice.LeftStickX.Value;
var v = _inputDevice.LeftStickY.Value;
« Last Edit: July 08, 2015, 08:47:59 AM by terri »

3noneTwo

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: InControl Custom Actions
« Reply #24 on: July 08, 2015, 09:23:28 AM »
How are you guys setting up the axis?
It seems like it should have a Left Stick X and Left Stick Y option, but it only has Up/Down/Left/Right.
I'm running into similar issues with "GetInControlDeviceInputAxis". I can't see any way to test Stick/DPad X/Y axes, only specific directions. Unfortunately I can't use the same workaround.

terri

  • Sr. Member
  • ****
  • Posts: 349
    • View Profile
    • terrivellmann.tumblr.com
Re: InControl Custom Actions
« Reply #25 on: July 08, 2015, 10:40:30 AM »
This is super bare bones but here is a Rumble action.

edit: Added better version with Everyframe/Reset on exit

« Last Edit: July 08, 2015, 01:16:28 PM by terri »

3noneTwo

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: InControl Custom Actions
« Reply #26 on: July 09, 2015, 11:39:06 AM »
I've created a temporary extension to 'Get InControl Device Input Axis', along with a set of OneAxisInputControl and TwoAxisInputControl enumerations. These scripts will not overwrite any actions, but they'll make it easier to set up axes!

I'm assuming the enumerations will help make it possible to implement TwoAxisInputControl as part of 'Get InControl Device Input Axis Vector', though I haven't attempted it myself.
« Last Edit: July 09, 2015, 11:50:27 AM by 3noneTwo »

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • View Profile
    • MABManZ.com
Re: InControl Custom Actions
« Reply #27 on: August 02, 2015, 03:12:57 AM »
Hi Jean,

InControl 1.5.0 introduced the ability to rebind actions/buttons at runtime, could Playmaker actions for these be implemented?

http://www.gallantgames.com/pages/incontrol-rebinding-at-runtime

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: InControl Custom Actions
« Reply #28 on: August 03, 2015, 12:32:28 PM »
Hi,

 Please bump me mid august, I won't have time before, Siggraph is coming soon :)

Bye,

 Jean

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • View Profile
    • MABManZ.com
Re: InControl Custom Actions
« Reply #29 on: August 16, 2015, 11:28:39 PM »
Bumping! Thanks Jean