How can i recreate the effects of proximity on the Ui layer

Im working on a game jam game and i need to sense if a object is on the same space as another one, its using a drag and drop, but idk how id do it, its a game jam game so PM for link

2 Likes

Does the object have to be in the UI?

its inventory and idk how to make it follow the player screen if its on game layer

1 Like

Oh, ok. If you want an object to follow the player like it’s in the UI layer, here’s what you have to do:

First, use extractors to always set the players X and Y velocity into two Globals. (In the player object.)

Second, get the two globals in the inventory object and set them to the X and Y inputs on a Velocity Behavior.

Then just set the inventory object’s display order to 500.

would i not use a postion block? velocity will just keep it moving

1 Like

yeah thats not working

1 Like

Can I see the game please? (In a PM, of course.) I think it would be much easier if I could examine the code myself. Maybe then I could even post the code needed to do this.

i might not do the drgging and dropping and do clicking instead because that wasnt working and i already deleted it

What do you mean by Draging and Dropping & Clicking?

sry lol, I need it to be able to drag something into a certain “slot” which its own object and when that happens it makes it when you click something else happens

2 Likes

you can recreate proximity by calculating the distance between the objects instead.

{"data":{"behavior":{"v":"2","nodes":[{"inputCount":2,"outputCount":1,"name":"Distance 1.0","behaviorType":"logic.NodeGroup","x":-90,"y":-16,"group":"","id":"b999a781355ebe4a","notes":null,"n_o":null,"isMenuItem":false},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":90,"y":192,"group":"b999a781355ebe4a","id":"b999a782d8e11b4b"},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":90,"y":32,"group":"b999a781355ebe4a","id":"b999a782768d6d48"},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-270,"y":64,"group":"b999a781355ebe4a","id":"b999a7827cb92c4d"},{"expression":"Math.sqrt(Math.abs(A*A) + Math.abs(B*B))","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":270,"y":96,"group":"b999a781355ebe4a","id":"b999a783362e9646"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":160,"group":"b999a781355ebe4a","id":"b999a783da756047","targetId":0,"prop":"y"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":-32,"group":"b999a781355ebe4a","id":"b999a783b9270b41","targetId":0,"prop":"x"},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":450,"y":128,"group":"b999a781355ebe4a","id":"b999a7839280754c","notes":null,"n_o":null,"portId":"b999a781355ebe4ao0","tag":"dist.","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":64,"group":"b999a781355ebe4a","id":"b999a783730b8647","portId":"b999a781355ebe4ai0","tag":"X","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":256,"group":"b999a781355ebe4a","id":"b999a7833912cd49","portId":"b999a781355ebe4ai1","tag":"Y","dataType":2}],"links":[{"input_id":"b999a783362e9646i1","output_id":"b999a782d8e11b4bo0"},{"input_id":"b999a783362e9646i2","output_id":"b999a782d8e11b4bo0"},{"input_id":"b999a783362e9646i0","output_id":"b999a782768d6d48o0"},{"input_id":"b999a783b9270b41i0","output_id":"b999a7827cb92c4do0"},{"input_id":"b999a783da756047i0","output_id":"b999a7827cb92c4do0"},{"input_id":"b999a7839280754ci0","output_id":"b999a783362e9646o0"},{"input_id":"b999a782d8e11b4bi0","output_id":"b999a783da756047o0"},{"input_id":"b999a782768d6d48i0","output_id":"b999a783b9270b41o0"},{"input_id":"b999a782768d6d48i1","output_id":"b999a783730b8647o0"},{"input_id":"b999a782768d6d48i2","output_id":"b999a783730b8647o0"},{"input_id":"b999a782d8e11b4bi1","output_id":"b999a7833912cd49o0"},{"input_id":"b999a782d8e11b4bi2","output_id":"b999a7833912cd49o0"}]}}}

This is a distance bundle, input X,Y and it will calculate the distance from this object and those coordinates.

Then add a filter, to control the radius or the size of this “proximity”:
Screenshot 2023-12-29 11.23.58 PM

Change the number to the radius or the size of the proximity you want. It shows 20 above, so it’ll output “pass” when the objects are less than 20 pixels apart.

This works if you want a circle shaped proximity. Tell me if you have any questions!

1 Like