Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: edwardr on March 14, 2017, 12:44:08 PM

Title: 2D Trigger (Drop to the right position) [SOLVED]
Post by: edwardr on March 14, 2017, 12:44:08 PM
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
Title: Re: 2D Trigger (Drop to the right position)
Post by: krane on March 14, 2017, 05:49:16 PM
There is a drag and drop prefab in the Ecosystem that will do what you want.
Title: Re: 2D Trigger (Drop to the right position)
Post by: edwardr on March 14, 2017, 06: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 :(
Title: Re: 2D Trigger (Drop to the right position)
Post by: jeanfabre on March 15, 2017, 04: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
Title: Re: 2D Trigger (Drop to the right position)
Post by: edwardr on March 15, 2017, 05: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)
Title: Re: 2D Trigger (Drop to the right position) [solved - somehow]
Post by: edwardr on March 15, 2017, 11: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 :(
Title: Re: 2D Trigger (Drop to the right position) [solved - somehow]
Post by: jeanfabre on March 16, 2017, 06: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



Title: Re: 2D Trigger (Drop to the right position) [SOLVED]
Post by: edwardr on March 16, 2017, 10:36:55 AM
Cool thank you,

but I can't find it in the ecosystem? :( (also with separate word)
Title: Re: 2D Trigger (Drop to the right position) [SOLVED]
Post by: jeanfabre on March 17, 2017, 01:52:45 AM
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
Title: Re: 2D Trigger (Drop to the right position) [SOLVED]
Post by: edwardr on March 20, 2017, 06:55:16 AM
thx found it, forgot to update