playMaker

Author Topic: 'Offset' in 2d Wave Mesh (Mega-Fiers)[SOLVED]  (Read 2200 times)

brendang

  • Junior Playmaker
  • **
  • Posts: 59
    • View Profile
    • Out to Play Interactive
'Offset' in 2d Wave Mesh (Mega-Fiers)[SOLVED]
« on: May 20, 2012, 11:54:26 AM »
I'm sure this could work for more than this one attribute.  But I'd like to be able to slowly increment the (texture) offset in this MegaShape within Mega-Fiers

Is there a generic way to access these type of attributes?

thanks,
B
« Last Edit: October 28, 2013, 11:25:53 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #1 on: May 24, 2012, 12:29:20 PM »
hi,

 Here we go :)

 I haven't put all the common parameters here, I think I would prefer cutting it down into sections actually, to avoid a messy do it all action that would most of the time be too much for the need.

Warning, some modifier will not react to the offset and some values of the position and rotation, simply work it out in the component itself, if that works, then this action will work too.

Code: [Select]

// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Mega-Fiers")]
[Tooltip("Set the transform common parameters of a Mega-Fiers modifier.")]
public class MegafiersSetModifierTransform : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(MegaModifier))]
[Tooltip("The GameObject to check.")]
public FsmOwnerDefault gameObject;


[Tooltip("The offset")]
public FsmVector3 offset;

[Tooltip("The gizmo Position")]
public FsmVector3 gizmoPos;

[Tooltip("The gizmo Rotation")]
public FsmVector3 gizmoRot;

[Tooltip("The gizmo Scale")]
public FsmVector3 gizmoScale;

[Tooltip("Repeat every frame")]
public bool everyFrame;

public override void Reset()
{
gameObject = null;
offset = null;
gizmoPos = null;
gizmoRot = null;
gizmoScale = new FsmVector3();
gizmoScale.Value = new Vector3(1,1,1);

everyFrame = false;
}

private MegaModifier megaModifier;

public override void OnEnter()
{

var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
megaModifier = go.GetComponent<MegaModifier>();

if (megaModifier == null)
{
LogError("Missing MegaModifier!");
return;
}


DoSetOffset();

if (!everyFrame)
{
Finish();
}
}

public override void OnUpdate()
{
DoSetOffset();
}

void DoSetOffset()
{
if ( megaModifier !=null)
{
if (offset.Value != megaModifier.Offset)
{
megaModifier.Offset = offset.Value;
}

if (gizmoPos.Value != megaModifier.gizmoPos)
{
megaModifier.gizmoPos = gizmoPos.Value;
}
if (gizmoRot.Value != megaModifier.gizmoRot)
{
megaModifier.gizmoRot = gizmoRot.Value;
}
if (gizmoScale.Value != megaModifier.gizmoScale)
{
megaModifier.gizmoScale = gizmoScale.Value;
}
}
}
}
}

If you need other functions, do not hesitate :) you can always use this action as a base if you have some scripting knowledge, else I can help out.


 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #2 on: May 24, 2012, 12:33:20 PM »
Hi,

 forgot to explain how to do that generically:

Create a Fsm Object variable, set its class to "MegaModifier", point it to the gameObject you want to control, and then use the action "set property", use that Fsm Object you have created, and you will access all the properties ( including the one I expose in this action). so you can pretty much control any component ( not just Mega Fiers ones)  anything this way.

Bye,

 Jean

t4d

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #3 on: October 23, 2013, 02:46:29 AM »
sorry where do i or how do i "set it's class" ?  to MegaModifier is that the name i should call the Variable ?

can you post a example playmaker tree or show how you would control a megafier values please sorry newbie but Loving playmaker great stuff  ;)

sorry learning alot, this gave me what i needed  ;)
http://www.youtube.com/watch?v=QVG-336_PsM

no sorrry any links or ideas how to connect to a C# script ?
« Last Edit: October 23, 2013, 11:07:42 PM by t4d »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #4 on: October 23, 2013, 11:58:19 PM »
Hi,

 Can you give me a concrete example. What modifier and what value do you want to actually control?

bye,

 Jean

t4d

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #5 on: October 28, 2013, 09:45:25 PM »
no need now but for everyone else who may read this ,. I was all Joy with i found you can just drag scripts into the Playmaker window and choose the value you need to control EASY with object with multi Magafier deformers just make sure you put in the ID value in as well and all is cool

Playmaker rocks Jean !!  ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)
« Reply #6 on: October 28, 2013, 11:25:41 PM »
Hi,

 yep, PlayMaker rocks big time!

bye,

 Jean

Headtrip

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: 'Offset' in 2d Wave Mesh (Mega-Fiers)[SOLVED]
« Reply #7 on: October 29, 2013, 02:33:46 PM »
Thanks!! I will try that!
Playmaker beyond rocks for me, its an absolute core component!