playMaker

Author Topic: joystick bridge for mobile  (Read 5624 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15050
  • Official Playmaker Support
    • View Profile
joystick bridge for mobile
« on: April 05, 2012, 11:23:31 PM »
Hi,

 I rolled a quick javascript action to plug with Unity mobile joystick ( found in penelop tutorial using the controls prefab ).

Check also this thread, it has a ready made package with a modified controls prefab if you want:
http://hutonggames.com/playmakerforum/index.php?topic=230.msg5664#msg5664

The next iteration would be to plug the number of touch on the joystick, allow for setting up the deadzone for example, etc etc.

Code: [Select]
import System;
import HutongGames.PlayMaker;

@ActionCategory(ActionCategory.Input)
@Tooltip("Gets system date and time info and stores it in a string variable")
public class JoystickBridge extends FsmStateAction{

//@RequireField
@CheckForComponent(typeof(Joystick))
@Tooltip("Store System DateTime as a string.")
public var gameObject : FsmOwnerDefault;

//@Tooltip("Optional format string. E.g., MM/dd/yyyy HH:mm")
public var position : FsmVector2;

public var verticalValue : FsmFloat;

public var horizontalValue : FsmFloat;

private var  _comp : Joystick;

public function Reset()
{
gameObject = null;
position = null;
verticalValue = 0f;
horizontalValue = 0f;
}

public function OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
_comp = go.GetComponent("Joystick");

}

public function OnUpdate()
{
position.Value = _comp.position;
verticalValue.Value = _comp.position.y;
horizontalValue.Value = _comp.position.x;
}



}

Bye,

 Jean

Groo Gadgets

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: joystick bridge for mobile
« Reply #1 on: April 09, 2012, 08:40:19 AM »
Heya,

I just downloaded this new action and I get the following error in the console:

Quote
Assets/PlayMaker/Actions/JoystickBridge.js(14,31): BCE0018: The name 'FsmVector2' does not denote a valid type ('not found'). Did you mean 'HutongGames.PlayMaker.FsmVector3'?

Does this action require another custom action to run?

Cheers,

Simon

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15050
  • Official Playmaker Support
    • View Profile
Re: joystick bridge for mobile
« Reply #2 on: April 10, 2012, 02:29:47 AM »
Hi,

 Yes, true, the Vector2 is only in beta for now, sorry I forgot.

 Please find a other version attached to this message, that will not fire any error.

 Bye,

 Jean
« Last Edit: April 11, 2012, 06:05:49 AM by jeanfabre »

Groo Gadgets

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: joystick bridge for mobile
« Reply #3 on: April 10, 2012, 08:53:34 PM »
Hey Jean,

I'm still getting an error:
Quote
Assets/PlayMaker/Actions/JoystickBridge.js(22,17): BCE0005: Unknown identifier: 'position'.

Simon

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15050
  • Official Playmaker Support
    • View Profile
Re: joystick bridge for mobile
« Reply #4 on: April 11, 2012, 06:06:40 AM »
Hi,

 should be gone now, forgot to remove the assignment line ( sorry, in and out rushing and running)

 bye,

 Jean

anbazia

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Re: joystick bridge for mobile
« Reply #5 on: April 11, 2012, 10:51:29 PM »
It works perfectly now, thans a bunch Jean