Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Propel Physics Object toward mouse click

Discussion in 'Scripting' started by timzydee, Mar 23, 2013.

  1. timzydee

    timzydee

    Joined:
    Mar 18, 2013
    Posts:
    8
    I've seen a lot of variations on this request but none of them are exactly what I need. I am new to coding so I can't just take snipets here and there. I need a javascript that will handle the following:

    A physics object will move toward the mouse click location at a constant rate of speed. After the click, the object will continue on in that direction and ignore any other clicks. I was using a script that would move the object to the exact position where the mouse clicked but that wasn't right because it just stopped dead at that position instead of continuing to travel on.
     
  2. joshimoo

    joshimoo

    Joined:
    Jun 23, 2011
    Posts:
    266
  3. timzydee

    timzydee

    Joined:
    Mar 18, 2013
    Posts:
    8
    Thanks for the tips. I'm aware of these functions, but being new to coding I was hoping to see them all put together in one javascript. That way I can learn how all this stuff fits together and how to implement it.