Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on April 06, 2012, 02:23:31 AM

Title: joystick bridge for mobile
Post by: jeanfabre on April 06, 2012, 02:23:31 AM
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 (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
Title: Re: joystick bridge for mobile
Post by: Groo Gadgets on April 09, 2012, 11: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
Title: Re: joystick bridge for mobile
Post by: jeanfabre on April 10, 2012, 05: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
Title: Re: joystick bridge for mobile
Post by: Groo Gadgets on April 10, 2012, 11:53:34 PM
Hey Jean,

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

Simon
Title: Re: joystick bridge for mobile
Post by: jeanfabre on April 11, 2012, 09:06:40 AM
Hi,

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

 bye,

 Jean
Title: Re: joystick bridge for mobile
Post by: anbazia on April 12, 2012, 01:51:29 AM
It works perfectly now, thans a bunch Jean