playMaker

Author Topic: Int value from script public fields to variable that an FSM can use. (Solved)  (Read 752 times)

Tzian

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
I really hate to do this but after trying so many different ways today, from trying to get this int value from one script to another or from my script to an FSM i am here tail between legs admitting defeat :(

I have looked at as many example i could find by google searching re. variables from script to script, and on here for script to fsm but i cant get any of it to work, im probably translating them to what i need incorrectly im sure.


so here goes

In my mapgeneration script i have a public int width and a public int height, they are being created randomly on awake and set in the field.

i know they are fine as my maps are generating correctly with these numbers.

i have a FSM attached to the ground gameobject, where i would like to use the width and height variables to scale the ground correctly to the size of map that has been created.

I have tried following the example here http://hutonggames.com/playmakerforum/index.php?topic=1759.0

checked script is  Using HutongGames.PlayMaker;
made public field   PlayMakerFSM MapGenFields;  (this is the FSM that is attached to the same game object as my script. Not sure how to code it for the drag and drop.

the example used String, so i thought poss i could just change that reference to Int, but i keep getting the error NullReferenceException: Object reference not set to an instance of an object.  it references this line of code on my script


Code: [Select]
        FsmString myFsmString = MapGenFields.FsmVariables.GetFsmString ("My string var");




I am probably not explaining this very well, and i am sorry if i have not followed proper etiquette re asking on forums, i forget things so easy :(

I am going to now go and see if i can find that way to put code up on here properly, sorry for the wall of text.

Regards
T.Z

p.s I can do voice comms if that is prefered by anyone, have PlayMaker Discord chat setup, just let me know a time relative to GMT :D
« Last Edit: February 25, 2018, 08:12:48 AM by Tzian »

Tzian

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Int value from script public fields to variable that an FSM can use.
« Reply #1 on: February 25, 2018, 06:31:39 AM »
A fresh start after some sleep and it would seem my googlefu is much better this morning, found this video, very straight forward and a lot simpler than some methods i have tried to grasp understanding of.  I can now see it changing the global variables in my FSM :D

« Last Edit: February 25, 2018, 07:25:09 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4614
    • View Profile
    • jinxtergames
Re: Int value from script public fields to variable that an FSM can use.
« Reply #2 on: February 25, 2018, 07:25:59 AM »
Hi,
Happy you got it to work, i boxed the video (looks cooler than a text link ;) )

Tzian

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Thanks for doing that :D

Have marked the topic solved, hope it helps someone in the future :D

Regards
T.Z