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.

Newcomers DBPro Corner / 3rd person camera

Author
Message
Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 13th Jun 2006 18:11
Im working on a 3D game in DBPro, in which you are flying a plane and you can shoot. I have the plane the plane to rotate according to the mouse position. For example, when you move the mouse to the right the plane would also rotate to the right, allowing you to steer the plane by moving your mouse.I tired using this:



But when I shoot the bullets always miss the crosshair. So basically I'm looking for a way to have a 3d object point the mouse position so when you shoot the bullets actually go to the crosshair. Thanks in advance
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Jun 2006 20:54 Edited at: 13th Jun 2006 21:04
i'm working on something similar which was inspired by another question along the same lines from a few days ago. i'm having some luck achieving the desired result by using a 3d crosshair (plain with a simple reticule texture) that always faces the player/ship object (rotating the reticule to match the ship's orientation) and remains 1000 units ahead/away. bullets (in my case, laser bolts) are then pointed to the 3-d reticule before firing (can't miss/will cross the reticule at a 1000 pt distance). in my version, the reticule is semi-independent meaning it moves up/down & left/right from what would be dead center in front of the ship (i don't know if yours is the same, or is it locked in at the "center", which would be even easier...) that is achieved by first placing the reticule directly in front of the ship, and then offsetting it (x and y) by mousemovex() and mousemovey() values each cycle.

the 1000 units i mentioned is what i want for my game. you'll need to adjust that based on your desired effect taking into account how fast your plane, enemies, bullets, over-all scale of your world, etc, are moving. hope this helped.

edit:

just remembered the title of your post included 'camera' and i didn't mention that. anyway, if you had a literal 3-d crosshair as i described, that's based on your plane's position and orientation, it would be accurate independent of any camera style or positioning you chose.

Virtual Nomad
Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb)
Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 13th Jun 2006 21:08
Yeah I thought about doing it thatway before, but I couldn't figure out how to make sure that the crosshair was always a set distance from the player. My crosshair is not locked at the center so if the player rotates the plane to the left 30 degrees I'm not sure how to find where the crosshair should be positioned. Could you help me out with this? Thanks.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Jun 2006 21:14 Edited at: 13th Jun 2006 21:18
basically, each cycle position the reticule at your ships coordinates, orient it to match the ship's angles, move it the desired distance ahead of the plane, then offset it with mousemovex() and mousemovey()

pseudo-code:


if you want to scale the movement rate of the offsets just set some variables up like:
xoffset# = mousemovex()*0.3
yoffset# = mousemovey()*0.3

and change the last 2 lines above to something like:
move object up Crosshair,yoffset#
move object right Crosshair,xoffset#

Virtual Nomad
Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb)
Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 13th Jun 2006 21:38 Edited at: 13th Jun 2006 21:38
Excellent! Thank you that worked like a charm. Now that I think about it that was amazing simple and I can't believ I didn't think of it.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Jun 2006 22:22
glad to help it's not a perfect approach (i'm sure there are better, more accurate ways) but in just a few lines of code, you can pull the effect off with a little tweaking & time. happy coding!

Virtual Nomad
Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb)

Login to post a reply

Server time is: 2024-09-25 01:26:58
Your offset time is: 2024-09-25 01:26:58