Pointers to drawing 2D meshes in game

Hello guys. My search abilities fail me, so I’m asking here.

How would I go about letting the player draw a straight line mesh, with collider?

Like if the player controls a ball, and needs to draw the ground on which the ball will roll?

Thanks in advance :slight_smile:

Im looking for help to create something like this.

Except simpler, only drawing a line with 2 points

Well, first off, you will have to catch the clicks of the user’s mouse. Then create a GameObject with a mesh that you created based on the clicks.
Look at http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html, specifically the Mesh From Scratch part.

If you don’t want the object you created to fall, then you would have to freeze the rotation and position in its rigidbody I believe (there might be a better way than that, but that is what I would do).

Edit:
Btw, look at http://docs.unity3d.com/Documentation/ScriptReference/Camera.ScreenToWorldPoint.html

Thanks a lot man!