playMaker

Author Topic: I cannot add the transform into "global variables object>transform"[SOLVED]  (Read 1375 times)

K3rne7

  • Playmaker Newbie
  • *
  • Posts: 8
Hi, just like the title, I've an issue with the global variables, in fact when I create a new global variables, and I choose the type of the new global variable like object, I select the type of object, "Transform", now, I want to put inside the field of this variables, the transform of my object, but it won't let me do that.  Even if I dragged the object it doesn't register and shows up "none".

I want to connect save and load buttons, so I need the global variable in the transform in order to connect both buttons with the same object (player).
In few words, I want to create save and load position for my player, through two buttons.

« Last Edit: July 10, 2020, 12:00:24 PM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: I cannot add the transform into "global variables object>transform"
« Reply #1 on: July 09, 2020, 10:37:18 AM »
Hi.
You can use game object and then in the fsm use actions like 'Rect Transform Get/Set Local Position'.

Also you probably should use local variables for this.

Try to minimize using globals.

Also its good to look to some tutorials to understand how Playmaker works, as it works different from other state machines :)

K3rne7

  • Playmaker Newbie
  • *
  • Posts: 8
Re: I cannot add the transform into "global variables object>transform"
« Reply #2 on: July 09, 2020, 02:32:04 PM »
Hi.
You can use game object and then in the fsm use actions like 'Rect Transform Get/Set Local Position'.

Also you probably should use local variables for this.

Try to minimize using globals.

Also its good to look to some tutorials to understand how Playmaker works, as it works different from other state machines :)

Hi djaydino, thank you very much for your answer, I have been using playmaker for two months, and I am falling in love with it, but for this problem I have not been able to find any tutorial, I have been trying for about 2 weeks, day and night, but nothing, the main problem is this.
How can I connect the transform of my player to two UI buttons, Save & Load?

I created a global variable> object> transform, and I dragged the cube of my scene into the transform field of the global variable, but isn't allow me, so I created a prefab of the cube and it worked, but when I drag the prefab into the scene, rightly the global variable receives the transform of the prefab in the asset, not that of the scene and does not update the position x, y, z of the player.

Imagine this, I have a UI, with two Save and load buttons, when I click on Save, I want the position of the player to be saved, but when I click load, I want the position of the player to be restored to the same place as before, for do this, shouldn't i save the position in a variable? But if I use the local variable, rightly, being the buttons 2, the variable will be present in the first button, but not in the second, to use the same variable for two buttons I have to use a global variable, but if I use a global one, it doesn't make me insert the transform of the player in the variable field.

I will tell you the truth, I know the difference between the transform and the rect transform in unity, but I have never used it as a playmaker, and I don't know how it works, among other things, looking for information on yt and google for months I have never had to deal with it, could you recommend a good tutorial with playmaker and with the rect transform?

Anyway, I wanted to thank you for your help, you can't imagine how much it means to me right now.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: I cannot add the transform into "global variables object>transform"
« Reply #3 on: July 09, 2020, 06:40:24 PM »
Hi.
Have a fsm anywhere and try this

State 1 :
Have 2 'Ui Button On Click Event' actions and connect 1 to save and one 2 load transition.

State 2 (save):
Use the action 'Get Postion' on the player and store in a variable.
Then loop back to State 1.

State 2 (save):
Use the action 'Set Postion' on the player and store in a variable.
Then loop back to State 1.

The Player You can set as a global variable (Game Object)
as you probably will communicate more with that object.


To use variables on other fsms/gameobject you can use Get/Set Fsm actions.

On the Ecosystem you can find more fsm actions, for example 'Fsm Bool Test'

K3rne7

  • Playmaker Newbie
  • *
  • Posts: 8
Re: I cannot add the transform into "global variables object>transform"
« Reply #4 on: July 09, 2020, 06:52:41 PM »
Hi.
Have a fsm anywhere and try this

State 1 :
Have 2 'Ui Button On Click Event' actions and connect 1 to save and one 2 load transition.

State 2 (save):
Use the action 'Get Postion' on the player and store in a variable.
Then loop back to State 1.

State 2 (save):
Use the action 'Set Postion' on the player and store in a variable.
Then loop back to State 1.

The Player You can set as a global variable (Game Object)
as you probably will communicate more with that object.


To use variables on other fsms/gameobject you can use Get/Set Fsm actions.

On the Ecosystem you can find more fsm actions, for example 'Fsm Bool Test'

Dear friend, without even doing it on purpose, I was going to write to you, I solved it in this way working on it, all day, but now I have a new problem, everything works, but the character controller, if it is active, does not make me save and load the game.
If I deactivate the CC, the game is saved and loaded and everything works, but of course I cannot move the character without the CC.

In any case, now I try what you have suggested, I am infinitely grateful for your help, also I saw the game you have in the signature, I think you developed it, and if it is as I imagine, I congratulate you, I find it wonderful, you must have put your soul into it.



Even if I write a code in C # for the movement eliminating the part of the code of the movement in the FSM, the problem of saving and loading that does not work always occurs, I found that the fault is always the Character Controller Component, I don't understand why, but I think that the CharacterController may conflict, in some way, with the saved Transform of the object, enlighten me, please, because I'm going crazy.
« Last Edit: July 09, 2020, 07:01:49 PM by K3rne7 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: I cannot add the transform into "global variables object>transform"
« Reply #5 on: July 10, 2020, 05:47:31 AM »
Hi.
You should split this into separate fsms.

Set movement in 1 fsm and add a state (call it disable for example)
Then make 2 Global Transitions call them Player/Movement/Enable and Player/Movement/Disable (try using this with the slashes, this will group transition events when you have to look for then)

set the disable to the disable state (the state can be empty)
and set the enable to the move state

Then on your Menu fsm.
When you activate the menu, send a event to the movement fsm to disable
and when you disable fsm you can enable movement again.

Character controller is good for prototyping else its better to build your own.
Standard movement you can do by using get axis and then set velocity.
Also you can restrict some rotations so it wont fall down.

Here is a video about transitions :


K3rne7

  • Playmaker Newbie
  • *
  • Posts: 8
Re: I cannot add the transform into "global variables object>transform"
« Reply #6 on: July 10, 2020, 11:00:08 AM »
ok, I've done in this way.
Look at this.



And now all work fine! If u want we can solved this post, thank u a lot for all ur suggests!
« Last Edit: July 10, 2020, 11:04:59 AM by K3rne7 »