How to create flying tokens that are attracted to you when you are near. Similar to the game mechanic from the Lego games.
Make your token. It could be a coin, shape, stud etc.
Make the detect zone the distance you want the studs to react to your player. I had it at the radius of a human laying down.
In the token brain:
WHEN DO [yaw][2] // This will make it spin in the world. Optional
WHEN [detect][player] DO
… WHEN DO [objvar:player][equals][it]
Instead of using the player tile throughout I create an object variable called player. This way if you have multiple players it will do the same for all of them, but only allocate the token to the one it detected.
…WHEN [countdown timer][0.5] DO [move][with flying][toward][objvar:player][center][position][min distance][0][directly]
This is the kode that will make your token move towards the player
…WHEN [bump][objvar:player]
…/…WHEN DO [objvar:player][numvar:stud counter][increment by][1] // I have used a number variable to count the number of tokens collected by the player
…/…WHEN [objvar:player][pick up][me]
…/…WHEN DO [play fx][Pick up Coin][at position][position]
…/… WHEN DO [play sound][UI collect Coin][volume][60]
This kode will remove the token from the world, increment a counter and play a visual effect and a sound. You can change the effect and sound to your own design.