playMaker

Author Topic: Accessing public Variables [SOLVED]  (Read 2637 times)

dicien008

  • Playmaker Newbie
  • *
  • Posts: 8
Accessing public Variables [SOLVED]
« on: February 24, 2015, 01:40:10 PM »
Hello.  I just purchased PlayMaker and can't wait to integrate it into my game.  I've already hit a big snag though.  It is about accessing public variables.  Yeah, I've read some forum topics about it.  Honestly what I've read has made no sense whatsoever.  Being that accessing other scripts are a big part of Unity, there must be a way for PlayMaker to access other scripts.

So here is the setup I'm trying to solve.  I've got a prefab with a lot of components on it (all written in c#).  I have one script (PieceScore.cs) which carries a public bool value that I need playmaker to access. 

The FSM is another component on the same game object.  Now if I needed to access it as a c# script, I could do:

PieceScore example = GetComponent<PieceScore>();

Then I could access all the public variables using:
//for example if the variable is named isSelected
example.isSelected;

Ok, so the first thing I tried using Playmaker is GetComponent.  Now here is where I get confused. GetComponent in playmaker doesn't allow you to specify a component to get.  Is it getting all the components on the gameObject?  Is it working at all?  All I can do is specify the game object and store it into a variable.  Not exactly what I was expecting. 

From there, GetValue.  Didn't help.  So its not working like I expected it would.  I must be missing something. 

I read something about using send method, but those are to functions.  All I need to do is read/write to an existing public c# variable.  I'm hoping that this won't mean a total rewrite from the ground up in order to do something that is simple in coding terms.  Not to mention that since doing something like this is a cornerstone of Unity itself, it had to be somehow integrated into playmaker. 
« Last Edit: February 24, 2015, 02:13:39 PM by Alex Chouls »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Accessing public Variables
« Reply #1 on: February 24, 2015, 02:08:53 PM »
Use Get Property and Set Property for grabbing variables out of scripts. You can actually just drag the script from the Inspector over to some blank space in the State tab and it will usually offer you the option of Get/Set property.

More detailed information and examples in this video:

Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

dicien008

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Accessing public Variables
« Reply #2 on: February 24, 2015, 02:12:41 PM »
Awesome!  I knew there had to be a way.  I hadn't come across that video in my search yet.  Thank you for pointing me in the right direction!