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 / 3D Mouse Coordinates not working

Author
Message
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 13th Aug 2009 04:25 Edited at: 13th Aug 2009 04:33
Hi! I'm working on a RPG and I just realized the my 3d mouse coordinate code does not work with the Y axis. It always positions my cube at position 0 on the Y axis (but it works perfectly for the X and Z axis). Here's the code I'm using:

I'm not sure why this is happening, so any help would be greatly appreciated!

Use Google first... it's not rocket surgery!
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Aug 2009 04:44
What did you intend for you code to do? By the looks of it you have a top-down facing camera(like in an RTS), and you're picking downwards by your height then accounting for the FOV by multiplying the output vector by the ratio between the height and final Y which I guess should always give you a Y of 0.

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 13th Aug 2009 04:48
Well tbh I didn't quite know how it worked because I found the code somewhere on here. What I mostly don't understand is what mult is for.

Use Google first... it's not rocket surgery!
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Aug 2009 05:09
It's the ratio I mentioned in my post, that code just projects a line from the camera by the mouse position to the plane lying flat on the X/Z axis with a Y of 0. Kind of like ray-casting to an infinite plane.

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 13th Aug 2009 05:14
Ahh ok. Do you know how to fix it? If not it's fine because I just made a work around that works perfectly but it probably uses a bit more resources. All I do is use Sparky's Ray Cast function to cast a ray from the x and z coordinates produced from the previous code from the camera's Y position to the character's Y position -500. I probably don't need it to be 500 below the player but it works . But the problem with this is that I can't have bridges but, I'm planning on making the level's like Baldur's Gate Dark Alliance so that really won't be necessary. Thanks for the info on the ratio though!

Use Google first... it's not rocket surgery!
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Aug 2009 05:20
Just replace dbCameraPositionY() in the first 2 statement lines by the difference in height between the camera and your player. But if your map has hills and stuff it's probably better to raycast your actual scene, but that depends on how your player movement works.

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 13th Aug 2009 05:59
Thanks but it doesn't detect everything so I'm just gonna stick with my previous ray cast code. Thanks for all your help!

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

Login to post a reply

Server time is: 2024-10-01 10:36:50
Your offset time is: 2024-10-01 10:36:50