playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jeanfabre

Pages: 1 ... 924 925 [926] 927 928 929
13876
Playmaker Help / Re: Enable / Disable Control Scripts functions?
« on: April 15, 2011, 02:40:38 PM »
Hi,

 Ok, screen cast for the first part done. I have to say at this point, I nearly gave up, I just couldn't record that screencast without making mistakes, too much caffeine in my blood at the moment  :P  If there is enough complain, I'll reshoot it :)

http://www.screencast.com/t/GyEFL5Tk8DHp

To explain a bit more on getting the pointer to the fsm component, I went for a slightly advanced wayin this screencast. There are other ways, I have made a small non exhaustive list of the most obvious ways:

 1: Declare a public variable:

Code: [Select]
public  PlayMakerFSM fsmInterface;
In the inspector, you then simply drag the gameObject with the fsm you want to talk to. Be careful it will pick the first fsm component attacched to that gameObject. So not ideal, but straight forward, not much coding involved. the nice thing as well is that the fsm can be on another gameobject, it's sometimes useful to have this kind of flexibility.

2: Access the first fsm component via code.

Code: [Select]
PlayMakerFSM fsmInterface = GetComponent<PlayMakerFSM>();
 Again, not ideal, because you can only access the first fsm component on that gameObject  like with technic 1.

3: A more versatile and flexible way ( used in the screencast and available in the code below )

 Scanning through all the fsm of that gameObject and pick the one matching the name you decide during authoring. The downside is that you need to be clean and name your fsm properly and take the time to reference it.


Hope you'll find it useful and clear enough. I will in a second screen cast use that script to enable disable the magnetic property within that fsm we created and use that to take the appropriate action when colliding with other objects. Then you'll have a complete example on how to achieve your goal using scripts and playmaker.

Bye,

Jean


Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;

public class TalkToFsm: MonoBehaviour {

// The name of the fsm you want to communicate with
public string fsmInterfaceName = "ScriptInterface";
// the related fsm pointer to fsmInterfaceName
private PlayMakerFSM fsmInterface;

// Use this for initialization
void Start () {

// run trough all the fsm attached to this gameObject and pick the one with the right name
PlayMakerFSM[] temp = GetComponents<PlayMakerFSM>();
foreach (PlayMakerFSM fsm in temp) {
if (fsm.FsmName == fsmInterfaceName){
fsmInterface = fsm;
break;
}
}

}


// Update is called once per frame
void Update () {

if (Input.anyKeyDown){

if (fsmInterface != null){

// send an arbitrary event
fsmInterface.Fsm.Event("MY SCRIPT EVENT");

// access and set an arbitrary value
fsmInterface.FsmVariables.GetFsmFloat("SomeRandomValue").Value = Random.value;


}

}
}
}

13877
Playmaker Help / Re: Deleting Actions
« on: April 15, 2011, 11:36:22 AM »
Hi,

 Simply do as for regular component attached to a game object, click on  the last "gear ish" icon on the Action bar ( on the right of the help icon "book" witha  question mark, and it reveals a menu where you can delete it. It's called "Remove Action"

 Bye,

 Jean

13878
Hi Alex,

 Yes, Finally got the time to run that simple test and it works  very well.

So yes, using Fsm.EventData.xxxData within your script get's properly caught by the GetEventInfo action : https://hutonggames.fogbugz.com/default.asp?W530

Bye,

 Jean

13879
Playmaker Help / Re: Enable / Disable Control Scripts functions?
« on: April 14, 2011, 04:34:38 AM »
Hi,

  Understood :)

  I'll shoot a screen cast hopefully within the next few hours to show you how you can achieve this.

 Bye,

 Jean

13880
Playmaker Help / Re: Enable / Disable Control Scripts functions?
« on: April 14, 2011, 04:21:30 AM »
Hi,

 Is that not simply a matter of maintaining a boolean value acting as a flag?

In your Fsm, you create a bool variable called MagneticEnabled

You then set it to true or false and when it collides, you check for that boolean and act accordingly like triggering an event or another/none.

the action to check for a boolean value is : https://hutonggames.fogbugz.com/default.asp?W76

 Do you have a problem in understanding how to do it in fsm, or simply how to do even if you could script it normally?

 Bye,

 Jean

13881
Yes,

 I don't like as well when there is too much actions in a state, Very much like when a function does too much, you'll likely find down the road that you will anyway need to split it to accomodate a usage you haven't planned. Divide and conquer :)


 Bye,

 Jean

13882
Playmaker Help / Re: does playmaker introduce overhead?
« on: April 13, 2011, 11:04:49 PM »
Hi,

 Yes, don't rely on the performance during editing, and check regularly how it performs when published. That true not just for playmaker but any thing you do with Unity ( and generally speaking for any framework).

 Basically, as always, It's a trade and balance between how fast and reliably you can achieve the desire result over how it will performs. If a system allows me great productivity and flexibility at the cost of few frames per secs: Deal as far as I am concerned. Then of course, DO-IT-ALL-IN-PLAYMAKER die hard will require careful profiling. But it's likely that in 99% of cases, playmaker overhead will be completely minimal and likely irrelevant compare to draw calls optimizations, GUI optimizations and physics optimizations.

 Bye,

 Jean

13883
Playmaker Tutorials / Moving a cube with user input
« on: April 13, 2011, 10:56:41 PM »
Hello Everyone.

 First screencast tutorial. Being able to move a cube when the user press the arrow keys or "w"/"s" ( more accuratly the actual "Vertical" Input define in Unity Input settings.

the screencast is here: http://www.screencast.com/t/0N6nZQsRcjt

The related original question in UA is : http://answers.unity3d.com/questions/51827/playmaker-basic-tutorial/51863#51863

The target audience for this are beginners and curious people willing to know more, or be convinced somehow before purchasing. This is of course not intended to be the ultimate/best way to go about it, but shows how easy and to the point PlayMaker is

 Several ways to improve this fsm if you want to take it further:

1 - When user input is 0, maybe we don't need to translate the cube of a null amount. That can/should be improved based on how you intend to use this (if the cube is meant to be moved around all the time during the game play, then this is fine as is).
2 - Moving speed setting and fine tuning is missing. A speed variable should be created and multiplied by the user input before translating the cube.
3 - If you plan on adding yet more flexibility, we would need to be able to choose the axis and direction of the move.

Bye,

 Jean

13884
Playmaker Help / Re: FunctionCall doesn't propose vector3
« on: April 13, 2011, 10:40:04 PM »
HI Alex,

 Excellent thanks.

 Bye,

 Jean

13885
Playmaker Tutorials / Screencast on how to move a cube
« on: April 13, 2011, 09:17:42 AM »
Hi,

 Again, not too sure where this should go, will move it if you shout :)

 Basically, following a question in UA, I ended up doing a screencast, cause that's the best way to show something we can't share  :-\

 The screencast is here : http://www.screencast.com/t/0N6nZQsRcjt

 The UA question itself is here: http://answers.unity3d.com/questions/51827/playmaker-basic-tutorial

Hope you'll find it useful, especially when you just don't know how playmaker actually works. So this is targeting beginners and curious.

 Bye,

 Jean

13886
Playmaker Help / Re: Textfield and button
« on: April 13, 2011, 08:35:29 AM »
Hi,

 Totally possible :)

String comparison action to trigger an event can be found here: https://hutonggames.fogbugz.com/default.asp?W408

Then you have a lot of different possibilities to get the string from the user. Let's keep it all in playmaker :)

You first need to create a variable that will hold the content of the textfield at start AND when the user is editing it.

You can display a gui text field with the following action : https://hutonggames.fogbugz.com/default.asp?W436
You can display a button using the following action :https://hutonggames.fogbugz.com/default.asp?W427

Look for the playmaker testLab samples on how to use GUI actions. The testlab samples are the first stop to learn playmaker.

Then you simply wire an event when the user is clicking on the button . That event triggers the State where you then compare the text of the textField with the string you want, and if equal, you trigger another event and do whatever you need on the State triggered by the successful comparison event.

 Does that make sense?

 Bye,

 Jean
 


13887
Playmaker Help / FunctionCall doens't propose vector3
« on: April 13, 2011, 08:06:26 AM »
Hi,

 Got caught by that one in the middle of writing an action.

 If you look at the SendMessage Action. The exposed set of properties to define the method name, and variable to pass if based on FunctionCall but the list of possible fsm variable to pick from doesn't show the vector3 ?!

Is there s logical reason for this? this was just the one I needed... :'(

Bye,

 Jean

13888
Share New Actions / Re: Int Compare And Flag
« on: April 13, 2011, 07:30:14 AM »
Can't find sarcasms neither. I guess it's just misunderstanding. Very useful action anyway :)

Bye,

 Jean

13889
Playmaker Help / Re: Button that triggers Closing the App?
« on: April 13, 2011, 07:25:31 AM »
Done,

 I whish we had some better official wiki system, cause even if it goes in the right section, maintaining code base in a forum is just wrong anyway.. but yes, in the right section now :) Obviously, the team is really busy and can't really afford playing on all sides, so if they'd let us build up a proper code base and documentation as we discuss things, double win!

 Bye,

 Jean

13890
Share New Actions / application quit
« on: April 13, 2011, 07:24:39 AM »
Hi,

 Just a simple application quit action.


Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.GameLogic)]
[Tooltip("Quit the application")]
public class ApplicationQuit : FsmStateAction
{

public override void OnEnter()
{
Debug.Log("APPLICATION QUIT");
Application.Quit();
Finish();
}
}
}

Bye,

 Jean

Pages: 1 ... 924 925 [926] 927 928 929