I'm not sure how to approach this.

Hello Unity people!

I’m trying to make a game (of course) and the part that I’m working on right now involves the player interacting with it. I have wrote the code for everything until the player has to actually play the game. So- balls are randomly moving around the (2D) board at a constant speed. The player needs to keep the balls from the middle so I wanted to do some type of drag and drop script. What I want to happen is that the player will see the ball coming towards the middle and touch the ball and drag out. Whichever direction that he drags is the new direction for the ball while the speed will stay the same. There are many balls bouncing around in the board so dragging can’t effect the other ones.

Some steps in the right direction would be great.

thanks

If you want to know “how” you can do that:

You will need Collider component in your balls, both for one u want to drag out and for others which moving around.
U can do a Raycast from mouse cursor position and check if it collide with your “balls with movement”. When u come to middle and take your “special ball to drag” u can just listen to it OnCollisionEnter event and check the name or tag of object, which Collide it, to know if it was one of your “balls with movement”.
There is one of many ways how to make that. Use Unity Script Reference )

You can use OnMouseDrag.

Here is a similar question, hope that helps.