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.
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