Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Mouse Position in 3D

Author
Message
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 28th Jul 2009 17:49
So many times I've searched for the solution to this, never found any results.

I finally decided to take a minute and think about it.

Here you go.



The pick variable will hold the ID of the object the mouse is over (you might want to adjust the object range), and p(x/y/z) will hold the position of where the mouse would effectively be if you were to push it "forward" from your screen until it hit something. Well... there's probably better explanations. "dist" will hold the distance from the camera to the 3D position of the mouse (right?).

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 28th Jul 2009 17:55 Edited at: 28th Jul 2009 18:00
Well here's the code I'm using for 3D Mouse Coordinates for my game:



Player.MovementVector is just an object I use so the player can point to it and move to it. But you can accomplish the same thing with a struct.

If you wish to do it with a struct put this in your variable declaration area:


Then instead of using:

use:


Now you have a virtual object without needing to make a box and such.

Use Google first... it's not rocket surgery!

Login to post a reply

Server time is: 2024-10-01 08:39:56
Your offset time is: 2024-10-01 08:39:56