is there a way to randomize the position transition of an object within a limited area? (using 2D sprite)
im relatively new to unity and im not sure how i can do this (example):
imagine 3 squares next to each other forming a triangle shape, all 3 as child of a big main circle. when certain button is pressed and hold down, it triggers that these squares repel from the center of the parent(the big circle in this case), after reaching certain distance from the center of the parent (between like 2-4 random meters or something), they start to move to random directions within a limited area, and when the button is released, they return back to their original position. all of this with smooth movement.
i thought about using the animator and some scripts, but on the script part i don't actually know how to do it (i have experience on c#)
my animator:
something like this im trying to do:
when button is pressed down and holded -> starts "RepelFromCenter" (which is where the squares repels from the center of the parent)
then, when squares reaches certain random distance from the center AND button is still hold down -> "RandomTrayectory" activates (where the squares starts to go in random directions within a limited area)
if button is released (from "RandomTrayectory" or "RepelFromCenter") -> start "ReturnToCenter" (where wherever the squares are, they will return to their original position)
after "ReturnToCenter" is over (over means once all the squares are back in their original position), it will go back to any of the 3 states at the bottom half
so, how should i make the script (in C#) to achieve this? or is there a better way to make this idea?