playMaker

Author Topic: Settinb a Vector3?  (Read 1892 times)

ShreddinPB

  • Playmaker Newbie
  • *
  • Posts: 4
Settinb a Vector3?
« on: April 19, 2012, 02:06:41 PM »
Hi guys, I am having a hard time finding information about how to set a playmaker variable from a variable that is in a script.

I have a gameobject that has a script attached to it. That script has a variable like this:

(I edited out all the other stuff that is not needed for this)
Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;

public class LevelAttributes : MonoBehaviour {

public Vector3[] quePositions = new Vector3[5];

void Start () {

setUpQue();
}

void setUpQue()
{
//Debug.Log("getting bubble size setupque");
bubbleSize = GameStateMenu.GetBubbleSize();

quePositions[0].x = shootFrom.x + (bubbleSize);
quePositions[0].y = shootFrom.y - (bubbleSize);
quePositions[0].z = shootFrom.z ;

quePositions[1].x = shootFrom.x + (bubbleSize*2);
quePositions[1].y = shootFrom.y - (bubbleSize);
quePositions[1].z = shootFrom.z ;

quePositions[2].x = shootFrom.x + (bubbleSize*3);
quePositions[2].y = shootFrom.y - (bubbleSize);
quePositions[2].z = shootFrom.z ;

quePositions[3].x = shootFrom.x + (bubbleSize*4);
quePositions[3].y = shootFrom.y - (bubbleSize);
quePositions[3].z = shootFrom.z ;

quePositions[4].x = shootFrom.x + (bubbleSize*5);
quePositions[4].y = shootFrom.y - (bubbleSize);
quePositions[4].z = shootFrom.z ;
      }
}


In the FSM for the gameobjects I then need to move to these positions depending on what state they are in.
I created Vector3 variables IN the FSM, but can not figure out how to set those variable from the script, or if thats even the best way to do it.

I tried adding objects, setting those objects positions in the setUpQue(), then using MoveTowards. That would only let me select the objects prefab (it wont let me set the one that is actually in the scene) as the object to move towards, so it moves towards its default position (0,0,0) and not its position that is updated in the scene.

So whats the best way to go about this?

Sorry if this is common knowledge, I just cant seem to find it in the manual :(


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Settinb a Vector3?
« Reply #1 on: April 20, 2012, 12:03:48 PM »
It seems like you should be able to do this entirely in Playmaker, having the extra script to interface with seems needlessly complicated. But maybe that script is doing more than that...?

Quote
That would only let me select the objects prefab (it wont let me set the one that is actually in the scene) as the object to move towards, so it moves towards its default position (0,0,0) and not its position that is updated in the scene.

Is the FSM a prefab? Prefabs in Unity can only reference other prefabs, not scene objects.

Typically you would need to "discover" these scene objects at runtime, e.g., using tags, or the hierarchy, or even naming conventions.

I'm not entirely sure what you're trying to achieve. Can you post a screenshot of your FSM?