Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started 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.
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
-
Heya,
I just downloaded this new action and I get the following error in the console:
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
-
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
-
Hey Jean,
I'm still getting an error:
Assets/PlayMaker/Actions/JoystickBridge.js(22,17): BCE0005: Unknown identifier: 'position'.
Simon
-
Hi,
should be gone now, forgot to remove the assignment line ( sorry, in and out rushing and running)
bye,
Jean
-
It works perfectly now, thans a bunch Jean