playMaker

Author Topic: Mouse Pick 2D Event - Bug?!  (Read 1245 times)

Maxi

  • Playmaker Newbie
  • *
  • Posts: 41
Mouse Pick 2D Event - Bug?!
« on: May 15, 2020, 11:39:52 AM »
Hi,
I am building a game with drag and drop of different objects. I am trying to work around this issue for a few days now, but however I design my scipt the error reapears;
After some Mouse Pick 2D Events it just stops to work on seemingly random objects. For example: I drag and drop a unit to another spot, drag another unit and so on one (or multiple) of them stop responding. I can see in the FSM that it is still waiting for a Mouse Over and is not deactivated. If I manually move the object in the editor it starts working again.
Are there known issues in regards to Mouse Pick 2d Event? Or could it be that it is bad practice to have like 20 objects waiting on every frame for mouse over?
Also: The Script is in a Template on a prefab which is created on runtime, could this be a problem? (Though the bug also appears if the script is not on a template)
Thanks!!
« Last Edit: May 15, 2020, 11:55:40 AM by Maximilian0 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Mouse Pick 2D Event - Bug?!
« Reply #1 on: May 16, 2020, 03:10:20 AM »
Hi.
What unity / playmaker versions are you using?

So far i did not encounter issues with them, only performance decrease when using a lot of them.

it might be better to use mouse pick instead.

here's a video show the mouse pick.

You can use layers to only pick those layers (or inverted)

if you also need to for example scale on hover you could make a separate fsm that does the 'mouse pick 2d' every frame.
and have a 'gameobject changed' action on the same state.
when changed check an array or array list (Array Maker) which should have the select able objects.

loop thru the objects and you can do a game object compare, and (for example) if not same Send event to the object to 'unselect' and if same send a event 'selected'
before looping you could do a 'gameobject null' test and if null broadcast the 'unselect' event instead.

Maxi

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Mouse Pick 2D Event - Bug?!
« Reply #2 on: May 16, 2020, 05:35:24 AM »
Hey, thanks for your reply.

I am using Unity 2019.3.13 (newest) and afaik the newest Playmaker Version.

I have already tried multiple solutions. The problem with mouse pick 2d is for me that it is not fast enough, since my objects are relatively close together it often missed the switch between two objects.

For now I read the Mouse Coordinates and let objects compare them to their own position with the tolerance describing their size. It works, but I guess it will be problematic on different screen sizes/ resolutions.

Anyway, maybe I'll give your method a try, thanks a lot :)