Author Topic: Move object to mouse click  (Read 1926 times)

Offline qwaqwe

  • byte
  • *
  • Posts: 1
    • View Profile
Move object to mouse click
« on: May 09, 2016, 03:57:13 pm »

I have a "world" and an object on it (2D). I want to click anywhere on the world and object should move  to the place of click. How can i do this?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
Re: Move object to mouse click
« Reply #1 on: May 09, 2016, 07:48:17 pm »
It depends. If your click happens on real geometry, you can evaluate the collision of the picking way with that geometry. If's there's no actual geometry where you are clicking, you can introduce a hidden plane that acts as a picking plane and is visible only in the picking calculation stage.

The code snippets section in the wiki contains a simple mouse follow demo that shows the basic idea: