PDA

View Full Version : How to move an object toward cursor?


daveelton
10-01-2006, 04:27 PM
Hello all,

I am looking for a way to have an object move toward where the mouse was clicked (a person is throwing an object into the distance, and gravity can be ignored for simplicity... a straight line throw toward the cursor is good enough). I thought about creating an invisible "target" and moving it to the location that the mouse is clicked at and then have the object move toward the target, but it turns out that even moving this target to the location of the mouse when it is clicked is more difficult than I had imagined... the only mouse related functions I can find are world.mouse distance from left edge and world.mouse distance from top edge... which I can think of a way to use these values if there is a way to find out the height of the world (the width shouldn't be as important since measurement from the left should start at 0), but I have not had any luck with finding that value either. Any ideas? Thanks in advance.

Mr Nemo
10-01-2006, 07:52 PM
Unless maybe one of the admins knows how to do it, I don't think it's possible, man.:(
You mentioned an invisible target. That would be a viable workaround, but you would have to cover the sky with hundreds, maybe thousands of such targets to get it to work.

DrJim
10-01-2006, 09:31 PM
Think the attached is the best you can do (see note).

It' kinda fun though.:D

Mr Nemo
10-01-2006, 10:47 PM
I've gotta say that's quite an interesting treatment of the problem. I can definitely say that I wouldn't have thought of that.:D

DrJim
10-01-2006, 11:43 PM
If you look at the main Alice screen, that's essentially how they handle camera and object movement - with, of course, a mouse click selection, the shift key to force movement normal to the plane (and a lot of normalization, I'm sure).

Jim

daveelton
10-02-2006, 07:07 PM
Thanks for the thoughts. I think what I'm going to try is to have several floating "near miss" targets around the actual target that the player is trying to hit and set each of their vehicles to be the actual target... just thought I'd throw the idea out there in case anyone else ever comes across a similar problem in the future.