Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on April 18, 2012, 02:10:37 AM
-
Hi,
I have been willing to make a full port of the fantastic Mega Fiers to PlayMaker, and lack of time simply prevented anything to happen until Scottyboombotz found a problem getting the vertex position out of a Mega-Fiers gameObject.
http://hutonggames.com/playmakerforum/index.php?topic=1414.0 (http://hutonggames.com/playmakerforum/index.php?topic=1414.0)
So indeed, custom actions are required, and here is one to start with. This action will do exactly what the standard GetVertexPosition Does but will work with Mega-Fiers, else Mega.Fiers would cease working as you query for the vertex.
[EDIT] Had a word with Chris West, and I have updated the custom action to better use the api.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Mega-Fiers")]
[Tooltip("Gets the position of a vertex in a Mega-Fiers GameObject.")]
public class MegaFiersGetVertexPosition : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(MegaModifiers))]
[Tooltip("The GameObject to check.")]
public FsmOwnerDefault gameObject;
[RequiredField]
[Tooltip("The index of the vertex.")]
public FsmInt vertexIndex;
[Tooltip("Coordinate system to use.")]
public Space space;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the vertex position in a variable.")]
public FsmVector3 storePosition;
[Tooltip("Repeat every frame. Useful if the mesh is animated.")]
public bool everyFrame;
public override void Reset()
{
gameObject = null;
space = Space.World;
storePosition = null;
everyFrame = false;
}
private MegaModifiers megaModifiers;
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
megaModifiers = go.GetComponent<MegaModifiers>();
if (megaModifiers == null)
{
LogError("Missing MegaModifiers!");
return;
}
DoGetVertexPosition();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetVertexPosition();
}
void DoGetVertexPosition()
{
if ( megaModifiers !=null)
{
switch (space)
{
case Space.World:
var position = megaModifiers.sverts[vertexIndex.Value];
storePosition.Value = megaModifiers.gameObject.transform.TransformPoint(position);
break;
case Space.Self:
storePosition.Value = megaModifiers.sverts[vertexIndex.Value];
break;
}
}
}
}
}
If you have any questions, or requests, feel free to post
Bye,
Jean
-
Hi,
Just a post to mention that I update the custom action, for a better usage of the Mega-Fiers api,
Thanks top Chris West for his tips.
Bye,
Jean
-
More MegaFiers stuff puh-leeeze. All these systems are putting my 3D app into the dirt for functionality;)
TIA
-
Hi,
Mega-fiers is on the target for a real treat, but I have pending projects, and I can only take that much... So I'd like to finish my vectrosity set of actions, release an alpha preview of my guiml system and then I will tackle Mega Fier!
As always, pm me of course if do need actions now.
Bye,
Jen
-
Jeanfabre...... You are as valuable as the internet....when it comes to Playmaker.:)
Thanks so much for all you do.
Kevin
devotid
-
is this meant to work with all the Mega-Fiers? I used bend on a fishing rod test and used get vertex position for the tip of the rod & positioned a cube on the tip (so i could see if it worked) the cube moves to the position of the rod tip when bending but the rod no longer bends. :(
-
Hi,
uhm odd, using my actions should not affect the mega fiers at all. Would you be able to share that scene so that I can debug that?
As far as I can tell, this action works on all mega fiers modifiers yes.
bye,
Jean