Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: blackant on April 02, 2019, 07:33:40 AM
-
Hi,
i'm writing actions for AI.NavMesh,
but there is a lot of custom type in there, and i would like to store them in fsm variable
for some i can do it easily,
but not always....
the problem for now is this one:
[ObjectType(typeof(NavMeshPath))]
public FsmObject PathObject;
it can be stored there without problem, but i cannot call it with PathObject.Value
i tested many variants without succes.
so i missed something but what ?
thanks
-
Hi.
have you tried :
PathObject.Value as NavMeshPath;
-
yes, just tested but doesn't work
have also tested:
(NavMeshPath)PathObject.Value;
-
Hi.
There is also a .RawValue.
it is also possible that you need to place the fsm var in a var first and then do what you are trying to do.
Can you share the script. you can use paste bin or paste here as code.
-
also tested Var but got same result, no implicit conversion possible between them
and .RawValue neither
here is the code:
[RequiredField]
[CheckForComponent(typeof(NavMeshAgent))]
[UIHint(UIHint.Variable)]
[Tooltip("The NavMesh Agent.")]
public FsmOwnerDefault Agent;
[ObjectType(typeof(NavMeshPath))]
public FsmObject PathObject;
NavMeshPath Path;
public FsmBool Success;
public FsmBool everyFrame;
// Code that runs on entering the state.
public override void OnEnter()
{
DoSetPath();
if (!everyFrame.Value)
{
Finish();
}
}
// Code that runs every frame.
public override void OnUpdate()
{
DoSetPath();
}
void DoSetPath()
{
Path = PathObject.Value;
Success.Value = Fsm.GetOwnerDefaultTarget(Agent).GetComponent<NavMeshAgent>().SetPath(Path);
}
what really bother me is that if i declare PathObject to be [ObjectType(typeof(NavMeshPath))]
why do i have to convert it's value again into NavMeshPath ??
byte are strange...
-
hi.
if i set :
Path = PathObject.RawValue as NavMeshPath;
i don't get errors
but i did not have time to test the script
you can also set it this way :
Success.Value = Fsm.GetOwnerDefaultTarget(Agent).GetComponent<NavMeshAgent>().SetPath(PathObject.RawValue as NavMeshPath);
then you dont need the path variable