Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

How to move an object with the mouse

Discussion in 'Scripting' started by Greg Farina, May 1, 2007.

  1. Greg Farina

    Greg Farina

    Joined:
    Apr 25, 2007
    Posts:
    47
    Hi,

    Could someone tell me how to make an object move by mousing over it, selecting it, and directing it where to go via mouse input? I would simply like to move a cube by using the mouse and have it constrained to move the same distance as the object's width and length. Thanks in advance!

    -Greg
     
  2. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Look at the Procedurals example project, specifically at the lightning scene. It has an example of this exact thing.
     
  3. Greg Farina

    Greg Farina

    Joined:
    Apr 25, 2007
    Posts:
    47
    Thanks! That answers the question! Would you happen to know how to constrain movement? For example if I only wanted to allow the player horizontal direction and constrain the movement to a short distance.