playMaker

Author Topic: Interface between script and playmaker  (Read 972 times)

Banzang

  • Playmaker Newbie
  • *
  • Posts: 1
Interface between script and playmaker
« on: April 03, 2018, 01:00:42 PM »
Hi guys, I've a problem with both C# and making the script speak with the fsm.

I could have complicated my life, I'm looking for a way as simple as possible to solve the problem.
I'm not a programmer, so my code is dirty, I left comments on purpose.
Please give me a hand to understand how to solve the problem, I don't want the solution already made by you experts, I want to learn.

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

public class DistanceCalc : MonoBehaviour
{
    public PlayMakerFSM fsm;
    public GameObject cube;

    public void Start()
    {
        FsmVector3 FirstPoint = fsm.FsmVariables.GetFsmVector3("First"); // I get the coordinates of the points
        FsmVector3 SecondPoint = fsm.FsmVariables.GetFsmVector3("Last"); // They are two because I want to shape rectangles,
                                                                         // thanks to the position of the mouse when the left click is pressed and when it is released.
        float x0 = FirstPoint.Value.x; // The coordinates of the third point
        float y1 = SecondPoint.Value.y;
        float b = (SecondPoint.Value.x - FirstPoint.Value.x); // The dimensions of the base
        float h = (FirstPoint.Value.y - SecondPoint.Value.y); // The dimensions of the height

        Vector3 ThirdPoint = new Vector3(x0, y1, 0);
    }

    public void Update()
    {
        Instantiate(cube, transform.position, transform.rotation); // instantiate a cube 1x1x1 from prefabs.. but where?
        cube.transform.localScale.x *= b; // I don't know what I wrote here, but the meaning was to scale the unit cube to give it the shape of the desired rectangle, from his base and height.
        cube.transform.localScale.y *= h;
    }
}

Also I would like to understand if this way of recalling variables from playmaker works or not?
Because I found the relevant documentation from the manual on the official site, but didn't mention how to perform the vector3 action.

Thanks a lot :D
« Last Edit: April 03, 2018, 01:02:30 PM by Banzang »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Interface between script and playmaker
« Reply #1 on: April 04, 2018, 03:08:41 AM »
Hi,

 yes, you get to fsm variables like that, this is fine.

Vector math are all pure c# once you get the vector3 value. what action do you want to perform via code? if you know simply open that action and see how it's been done. Have you tried?


 Bye,

 Jean