Hi,
not sure, but I could not find it ( I swear I remember I did that action before...)
but here it is, sometimes it a lot easier to get the mouse position as a vector3 for further operations.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
//
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Gets the Vector3 Position of the mouse and stores it in a Variable.")]
public class GetMousePosition : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmVector3 mousePosition;
public bool normalize;
public bool everyFrame;
public override void Reset()
{
mousePosition = null;
normalize = true;
everyFrame = false;
}
public override void OnEnter()
{
DoGetMousePosition();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetMousePosition();
}
void DoGetMousePosition()
{
if (mousePosition != null)
{
Vector3 _mousePosition = Input.mousePosition;
if (normalize)
{
_mousePosition.x /= Screen.width;
_mousePosition.y /= Screen.height;
}
mousePosition.Value = _mousePosition;
}
}
}
}
bye,
Jean