www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: qwaqwe on May 09, 2016, 03:57:13 pm

Title: Move object to mouse click
Post by: qwaqwe on May 09, 2016, 03:57:13 pm
hi

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?
Title: Re: Move object to mouse click
Post by: EgonOlsen 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: http://www.jpct.net/wiki/index.php?title=Main_Page#Code_snippets_and_other_tips (http://www.jpct.net/wiki/index.php?title=Main_Page#Code_snippets_and_other_tips)