Hi,
Ok, here is a corrected version of this action.
1: notice that I am using the hutongs namespace, not sure if it play a role, but I always built actions like that.
2: you had an c# error, you cannot set the components of a vector without making it first as a variable
3: I removed redundant code, so now it's cleaner and easier to maintain.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("gets point along a circle for naval route purposes")]
public class FloatCircleCalculate : FsmStateAction
{
// distance from target point
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat distanzaPuntoTarget;
// target point
public FsmVector3 posizionePuntoTarget;
// ship point
public FsmVector3 posizioneNave;
// angle between ship and X
public FsmFloat angoloNaveSuX;
// angle between ship and target point
public FsmFloat angoloNaveSuTarget;
// temporary point of route
public FsmVector3 puntoDiRotta;
// check box for every frame
public bool everyFrame;
// Code that runs on entering the state.
public override void OnEnter()
{
computePoint();
if (!everyFrame)
{
Finish();
}
}
// Code that runs every frame.
public override void OnUpdate()
{
computePoint();
}
private void computePoint()
{
if (angoloNaveSuTarget.Value != 0) {
Vector3 _puntoDiRotta = puntoDiRotta.Value;
_puntoDiRotta.x = posizioneNave.Value.x+distanzaPuntoTarget.Value*Mathf.Cos(angoloNaveSuX.Value*Mathf.PI/180);
_puntoDiRotta.z = posizioneNave.Value.z+distanzaPuntoTarget.Value*Mathf.Sin(angoloNaveSuX.Value*Mathf.PI/180);
puntoDiRotta.Value = _puntoDiRotta;
}
}
}
}
Bye,
Jean