Unity Community


Results 1 to 4 of 4

  1. Posts
    6

    Make a gameobject follow the mouse when pressed held?

    I need my gameObject to follow the mouse then I hold down the left mouse button.

    Similar to this; http://youtu.be/4PVGwmAotJM?t=16s

    When she touch the screen, the character moves towards the place the stylus in held down.

    So let say my gameObject is the character in the video, and when I hold down the mouse button the gameObject "walks" towards it.

    A little help here?

    Thanks.


  2. Location
    Latvia
    Posts
    251
    You could try to use something like http://docs.unity3d.com/Documentatio...ePosition.html to get the 3D coordinates of the mouse cursor. The easiest way would be to use http://docs.unity3d.com/Documentatio...rm.LookAt.html and to move the character in that direction, but you would still run into problems with path finding assuming that you can have such problems. If not - this should probably work, but most probably isn't a great way to do it.

    I'm also not sure if this will work for mobile applications since I never touched them.


  3. Posts
    6
    Thanks, I will check it out.


  4. Posts
    326
    to add what @shadox said, if you are using 3rd party app for pathfinding (i'm sure you havn't done it yourself 'cos asking this kind of things) ,just put given value from mouseposition to target position ..or desired pos, whatever it is in system you using. Then again, if you dont have any pathfinding nor move system you might want to check: http://answers.unity3d.com/questions...-object-b.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •