playMaker

Author Topic: 2D Trigger (Drop to the right position) [SOLVED]  (Read 246 times)

edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
2D Trigger (Drop to the right position) [SOLVED]
« on: March 14, 2017, 09:44:08 AM »
Hi

I want to build a drag and drop FSM. The drag and drop is not a problem (with the help of easy touch), but my "deluxe" dream-version is making troubles..

What I want:
Drop it over (approx.) a 2nd object and a new FSM will start (e.g. destroy the object and replace it with a new object at a certain position - so you have the illusion it's "magical" moved to the right place)
Drop it outside a 2nd object, the object will go back to the beginning position

Like Solitary where the cards go to the right place.

The problem:
I tried with 2D Trigger but it doesn't start any other FSM. It just wait for something. I tried also other functions but it doesn't worked.

has somebody any idea where the problem can be?

PS: I added the file, but you will need easytouch5
PPS: I searched the forum, but didn't found any solution
« Last Edit: March 16, 2017, 03:55:44 AM by jeanfabre »

krane

  • Junior Playmaker
  • **
  • Posts: 63
    • View Profile
Re: 2D Trigger (Drop to the right position)
« Reply #1 on: March 14, 2017, 02:49:16 PM »
There is a drag and drop prefab in the Ecosystem that will do what you want.

edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: 2D Trigger (Drop to the right position)
« Reply #2 on: March 14, 2017, 03:13:20 PM »
the drag and drop is not the problem. it's more:

is the object over the other? if yes do this, if not do this.

I tried it without the drag and drop function by putting both 2D object about each other, but it's also not working :(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: 2D Trigger (Drop to the right position)
« Reply #3 on: March 15, 2017, 01:24:28 AM »
Hi,

 with uGui it's tricky unfortunatly, because it's a different system.

so to the question "Is the object over the other", there is no easy solution, you could use 2d triggers, BUT make sure you resize them properly as they do not automatically fit the UI element.

Let me if that works for you, I think it would be a good thing that I create a small component that keep colliders size matching their UI element like so: http://stackoverflow.com/questions/35477964/how-to-make-2d-colliders-scale-with-the-ui-element-theyre-bound-to


 Bye,

 Jean

edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: 2D Trigger (Drop to the right position)
« Reply #4 on: March 15, 2017, 02:49:59 AM »
the difference between an expert and a beginner: Uhhh????

2D Trigger is what I tried to do, need and understand, but the resize???? (sorry for my inexperience)

edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: 2D Trigger (Drop to the right position) [solved - somehow]
« Reply #5 on: March 15, 2017, 08:39:07 AM »
ok I solved it somehow...  Maybe it's not so professional, but it works...

I use Vector3 Compare / Vector2 Compare, which I downloaded from the Addon EcoSystem.

There I put in the 1st Variable the Vector3 Coordinate, where I drop the object and in the 2nd Variable the Vector3 Coord., where it should be.
The Tolerance is the "area" around the 2nd Variable (as I understand / see)

If it's equal it goes to my "Inside" State and if it's not equal it goes to my "Outside" State.

What do you think? A nice solution or crap??

PS: There is one problem:
This works only if the object / area is a square/box, because the tolerance is around one coordinate (in this case the middle of the object) So if the object is one side longer or has a different form, it won't work on the side.
So this should be solved with "is the object over the other object", but I don't understand what is meant with "resize". - I guess something simple, but I'm too stupid for it :(
« Last Edit: March 15, 2017, 08:49:43 AM by edwardr »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: 2D Trigger (Drop to the right position) [solved - somehow]
« Reply #6 on: March 16, 2017, 03:55:28 AM »
Hi,

 ok, I have done a component you can just drag and drop and it will work and totally
match your collider with your UI rectTransform :)

you can get it in the uGui Proxy full package on the Ecoystem, it's called:

 BoxCollider2dMatchRectTransform

https://twitter.com/JeanAtPlayMaker/status/842327318441910273

Bye,

 Jean




edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: 2D Trigger (Drop to the right position) [SOLVED]
« Reply #7 on: March 16, 2017, 07:36:55 AM »
Cool thank you,

but I can't find it in the ecosystem? :( (also with separate word)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: 2D Trigger (Drop to the right position) [SOLVED]
« Reply #8 on: March 16, 2017, 10:52:45 PM »
Hi,

 it's part of uGui Proxy full package. but you can get it directly here if you want:

https://github.com/jeanfabre/PlayMaker--Unity--UI/blob/master/Assets/Scripts/uGui/BoxCollider2dMatchRectTransform.cs

Bye,

 Jean

edwardr

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: 2D Trigger (Drop to the right position) [SOLVED]
« Reply #9 on: March 20, 2017, 03:55:16 AM »
thx found it, forgot to update