Search Unity

Dynamically Drawing a Trajectory Path for a 2D Game

Discussion in 'Scripting' started by DigiLusionist, Jun 10, 2012.

  1. DigiLusionist

    DigiLusionist

    Joined:
    Apr 30, 2007
    Posts:
    213
    For my 2D game, I am looking for a way to dynamically draw a 2D trajectory path along a curve when the player Left Mouse clicks and holds on the Player-Character sprite (the way the trajectory path is displayed in Angry Birds).

    Then, as long as the player continues to hold down the LMB, and drags the mouse, the angle / shape of the trajectory dynamically changes.

    How would such a thing be coded in Unity?

    For example: I click and hold on the character sprite and the arc trajectory appears. As I drag the mouse around, the angle of the arc that is displayed changes. Then, when I release the LMB, the character sprite moves (aligned) along that path.

     
  2. sherlockturtle

    sherlockturtle

    Joined:
    Jan 23, 2012
    Posts:
    592
    Are you looking for how to script it or for how to make a line?
     
  3. DigiLusionist

    DigiLusionist

    Joined:
    Apr 30, 2007
    Posts:
    213
    I am looking for suggestions on how to make the trajectory arc display as a 2D element, based on the mouse dragging.