playMaker

Author Topic: Set variable in script from playmaker  (Read 2948 times)

LightSoftStudio

  • Guest
Set variable in script from playmaker
« on: March 26, 2013, 08:25:33 PM »
how can i get a playmaker value set a variable in a script?
This is my code so far.

#pragma strict
 
var spawnPoints : Transform[];  // Array of spawn points to be used.
var enemyPrefabs : GameObject[]; // Array of different Enemies that are used.
var amountEnemies = 20;  // Total number of enemies to spawn.
var yieldTimeMin = theFsm.FsmVariables.GetFsmInt("Int").Value;
var yieldTimeMax = 5;  // Don't exceed this amount of time between spawning enemies randomly.
var i : int;
public var theFsm : PlayMakerFSM;
 
function Spawnblock()
{
    for (i=0; i<amountEnemies; i++)
    {
      yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));  // How long to wait before another enemy is instantiated.
 
      var obj : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.length)]; // Randomize the different enemies to instantiate.
      var pos: Transform = spawnPoints[Random.Range(0, spawnPoints.length)];  // Randomize the spawnPoints to instantiate enemy at next.
 
      Instantiate(obj, pos.position, pos.rotation);
}}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set variable in script from playmaker
« Reply #1 on: October 17, 2017, 02:53:42 AM »
Hi,

 you would do

theFsm.FsmVariables.FindFsmFloat("your variable name").Value;

Bye,

 Jean