Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dynamic shapes based on mouse movement

Discussion in '2D' started by labrat, Dec 30, 2013.

  1. labrat

    labrat

    Joined:
    Dec 30, 2013
    Posts:
    1
    Is it possible to track mouse movement (while a mouse button is down), record the mouse positions, and then programmatically create a 2D object that has the same shape that the user traced out with the mouse? That is, if the user drags the mouse in a square pattern, the code creates a square object; if they drag the mouse in a circular fashion a circle would be created. It would be best to be able to make any irregular polygon shape.

    I know that Unity 2D doesn't like to draw lines, and I don't think line drawing on the GUI would be helpful since I need the resulting objects to interact with sprites in the game; but I'm hoping that there is some way to create irregular polygon objects in code so that I can just capture mouse movements and convert them into polygon vertices of dynamically created objects.

    Is any of this possible with Unity 2D tools?