playMaker

Author Topic: Set Property not working for PlayMaker Ui Drag/Drop Events  (Read 2739 times)

stevvers

  • Playmaker Newbie
  • *
  • Posts: 9
Set Property not working for PlayMaker Ui Drag/Drop Events
« on: February 01, 2020, 03:11:13 AM »
I'm trying to add FSMs to the list of Playmaker Ui Drag and Drop events, but the Set Property action doesn't seem to work with it. Whether I use variables to get the FSM Object from a GameObject variable, or just manually drag and drop another GameObject with an FSM into the field within the action, the action just doesn't add anything to this element.

I'm assuming these elements are how I can drag through multiple UI elements, but I can't seem to find any documentation on them.

The objects that I want to drag through are created at runtime from prefabs, so I can't manually add them to these elements.

Any tips?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #1 on: February 04, 2020, 05:14:12 AM »
Hi,

 Could you make a screencast or some screenshots, I am really not sure where you are and what is not working as expected, thanks :)

Bye,

 Jean

stevvers

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #2 on: February 05, 2020, 04:18:48 PM »
Hi Jean,

Sorry, I should have included more info in my original post.

A brief outline of the game setup: I have a grid of gameobjects created from prefabs. I want the user to be able to drag a line across the grid, activating each gameobject as the drag action crosses it.

Currently, my prefabs have within their FSM to generate an array of the adjacent objects. My goal was to add these adjacent gameobjects to the UI drag and drop event elements, so that drag events can conveniently be passed between adjacent gameobjects.

I hope that makes sense! Please let me know if I can elaborate on anything.

I think part of the issue is that 'set property' is not exactly what is needed in this instance. Since the drag and drop elements appear to work like arrays, we need the ability to 'add property' to this element.

Anyway, here are some screenshots of the FSM I'm trying to use to populate these elements.

To make things even more confusing, these actions somehow wipe my array list. These actions are situated immediately after the generation of the 'Adjacents' array list. If I bypass these actions, the Adjacents array remains intact, but if they are included, it is empty, so it's definitely something happening in these two actions.

I'm at a bit of a loss, so any help you can provide would be greatly appreciated!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #3 on: February 06, 2020, 05:32:52 AM »
Hi,

 first of all, you don't specify the fsm name on your first action to get the fsm object. that needs to be set for this to work.


second, I would not do this like, there are several other ways:

- have on each grid objects ( how many cells do you have?) checking their own rect against the current segment being drawn,

- build a trigger based system, where the line is represented by a Box Collider ( or if in 2d, a rectangle collider), each of your cell have also a trigger, and so you can query for all the object currently intersecting. you can do that from each cells as well, which might be better if you want to animate the selection as the lien is being drawned and moved around.

I would personnaly go with the trigger based system, which prevents you from doing complex math to figure out what is being interected by the line.


if you want to do it still the way you started, make sure you reference properly the fsm name and let's take it from there if you still struggle.

Bye,

 Jean

stevvers

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #4 on: February 06, 2020, 07:31:09 AM »
Hi Jean,

Thanks for the comprehensive reply!

I must admit I've never had issues before when the FSM I'm targeting in an action is the only FSM on the gameobject in question, as is the case here. Regardless, I tried adding the FSM name, and somehow this seems to fix the issue with the array list that was getting wiped by these actions, but the drag/drop elements still aren't getting modified by the 'set property' actions.

Sorry, I don't think I've done a very good job of explaining what I'm trying to achieve. The line I described previously is not an actual onscreen line, but instead the 'line' I was describing is simply the path of the user's mouse (or, as the target platform is android/ios, the path of the user's touch).

The only onscreen line I'm using is simply to display the links built between each of the grid items. I've attached a video here displaying the concept. I've managed to get it partly working using UI Pointer Down/UI Pointer Enter/UI Pointer Up, but I can't seem to direct UI Pointer Up to the correct object (ie the object under the mouse when the pointer goes from down to up). This is what I was hoping to achieve with the UI drag/drop function.

I tried using triggers initially, but had issues with the mouse down and mouse up not being registered on UI elements (which my grid is made up of). I'll have another look at getting this working using mouse up/down together with trigger enter 2d, but as I will be using touch input ultimately, and my game is only UI, I thought it best to stick to the UI input functionality.

I'm open to taking a different approach, but I need something that can easily be tested on mouse while I develop, then ported to touch input when the time comes. I look forward to hearing your input!

Thanks in advance,

Steve

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #5 on: February 06, 2020, 07:37:03 AM »
Hi,

 ok that makes more sense. I assume this is using Unity UI.

For this, the best way is indeed to use triggers, make a small trigger on each of your cell ( smaller than the cell itself to allow for a treshold of selection).

 and on each of these trigger, you can have a simple fsm that catched mouse down and/or enter and that's it, that's all you need to register that cell as being selected. send a global event from that cell to a manager that keeps the sequence of cell in order of selection. Your manager can also create the links between the previous selected cell and the newly selected cell.

Don't over think this, it's simple.

If you struggle with this, I can do a quick sample.


Bye,

 Jean

stevvers

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #6 on: February 07, 2020, 02:06:31 AM »
Hi Jean,

Correct, this is using Unity UI.

I attempted to use triggers initially, but couldn't seem to get them to register input with the UI layers. I've tried again switching my events to trigger enter/exit 2d and mouse up/down, and still the FSM doesn't receive the input. When I use the same FSM and use UI pointer up/down/enter events instead, they work (but with some issues) as shown in the video I attached earlier.

I've attached images of the layout and the collider I'm using. Hopefully you can pinpoint what I'm doing wrong.

Thanks in advance,

Steve

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #7 on: February 07, 2020, 02:34:28 AM »
Hi,

 with UI, you don't need a collider for trigger, simply use the global UI pointer events for this, UI POINTER ENTER and UI POINTER CLICK

Bye,

 Jean

stevvers

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #8 on: February 07, 2020, 07:13:58 AM »
I'm very confused, I thought you were saying colliders & triggers was the most efficient way of doing it!

Back to the original issue, UI Pointer Down & Up seem a little unreliable in terms of which FSM receives the 'Pointer Up' message. It appears as though it is sometimes sent back to whichever FSM sent the original 'Pointer Down', rather than the FSM behind the cursor when the mouse button is released. I haven't been able to track down exactly what causes this.

That's the reason that I was hoping drag & drop would give me better results rather than pointer up & pointer down, but as far as I can tell, to drag on one item and drop on another, the two items need to be linked by the PlayMaker Ui Drag/Drop Events elements mentioned in my original post.

However, I can find no way to add items to those elements as the Set Property action doesn't appear to work with these elements.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property not working for PlayMaker Ui Drag/Drop Events
« Reply #9 on: February 10, 2020, 01:29:24 AM »
Hi,

 yeah... sorry. Indeed I think I though that you where in a regular 3d physic scene...

I never had issues with pointer events, maybe your sprites are intersecting?

pointer Up will be called on the object that had its pointer down triggered, that's what is maybe throwing you off.

 here's how I did it, with a single fsm.




to feed these selection into an array, simply broadcast it and have a second fsm sitting in your scene that catches these events and adde them into an array.

 have a go, if you are still struggling, I'll send you that sample scene.

Bye,

 Jean