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 / Help with 3rd person rotating and zooming!

Author
Message
McChief
20
Years of Service
User Offline
Joined: 24th Mar 2004
Location: USA
Posted: 16th Oct 2005 03:17
I have cobbled together a camera system for an RTS game from a couple different projects, since I have very little coding experience of my own. The code seen here is courtesy of XTOM of Team XTC (creator of Dark Konflict) and Kensupen & Lokidecat of Nerdsoft Creations.

I need help with the following items: When I you rotate the view (holding down the mousewheel) and try to move forward, backward or side to side, the camera doesn't move forward in the new angle (please run the code below to see what I mean). How can I get the camera to move forward in the direction the camera is pointing?

Also, I would like add zooming using the mousewheel - mousewheel up zooms out and mousewheel down zooms in. Also, I'd like to set maximum and minimum zoom levels.

Anyone's help with these items would be hugely appreciated!

Thank you much!
Grossman
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Russia
Posted: 16th Oct 2005 03:41 Edited at: 16th Oct 2005 03:42
Quote: "Also, I would like add zooming using the mousewheel - mousewheel up zooms out and mousewheel down zooms in. Also, I'd like to set maximum and minimum zoom levels."
You can make zoom effect by the set camera fov function. Mousewheel event can be captured by mousemovez(). Try to use something like I've written below in your main loop (it's a template!):

Note: I used cond variable for clarity reasons .
McChief
20
Years of Service
User Offline
Joined: 24th Mar 2004
Location: USA
Posted: 16th Oct 2005 06:51
Grossman,

Thank you for your help... I don't seem to be getting it to work however, when I run it. It just flips the field of vision upside down and back again when I roll the mousewheel. I am sure I'm doing something wrong and I tried plugging in different numbers in the < and > areas... I know you said your code is a template, but it looks like I don't know enough to customize it to my application. What should I try?

Your help is appreciated!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2005 00:12
Quote: "I have cobbled together a camera system for an RTS game from a couple different projects, since I have very little coding experience of my own"


Although it may not help directly with your problem, I've covered camera control on my web site and reading it might give you a bit of an insight into how to fix your own problem or write your own routines.

There are three types of camera control covered.

Link in sig at bottom.

TDK_Man

McChief
20
Years of Service
User Offline
Joined: 24th Mar 2004
Location: USA
Posted: 17th Oct 2005 02:28
TDK,

Thanks for the link, I'll take a look and see what I can figure out. Appreciate the heads-up.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Oct 2005 15:34 Edited at: 17th Oct 2005 15:36
In some cases limbs are easier to work with and to understand than maths, if so here's the basics of creating a 3rd person cam using limbs:

Add a limb to your character

Use the offset command and offset it at the distance you want, BUT for the z offset, instead of entering a number enter a variable, something like OFFSET#

Define OFFSET# as the z offset you want before you offset the limb

Now every loop position the camera at the limbs position, point the camera to the users position, and increase OFFSET# by the mousemovez() data, eg:


For moving the camera with the mouse, find the generic mousemovement code that so many people use in FPS's and plug it in, it'll still work even if youre not in first person view.

Goodluck.


FITZ
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: United Kingdom
Posted: 18th Oct 2005 09:38
I used this type of camera movement in 3rd person system has Zoom, but not with mousewheel use key's {1},{2} to zoom in and out. And arrow keys to move and rotate.



Hope it helps?


(Resistance is futile!)
McChief
20
Years of Service
User Offline
Joined: 24th Mar 2004
Location: USA
Posted: 20th Oct 2005 04:46
FITZ,

Thanks I'll have a look at it!

Anyone have any ideas on how to move in the direction that the camera has rotated?
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 20th Oct 2005 05:22
My method does just that...

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 20th Oct 2005 20:11 Edited at: 20th Oct 2005 20:12
3rd Person View w/ Rotating and Zooming Snippet
DBP - May work in DBC aswell



Breakdown:

Object 2 is a dummy object, it has a limb offset at the starting position you want the camera at. Every loop the camera is positioned at this limb's coordinates and pointed to object 1. Also, every limb the dummy object 2 is positioned at object 1's coordinates, now the camera will follow the user as they move.

Next we use the basic mouse looking code used in a lot of FPSs nowadays on DBP, and alter it a bit. We only rotate object 1 on the y axis and not the x axis so the user can't fly around, and then we rotate object 2 on yhe y and x axis so the user can look in all directions as the mouse moves.

Finally, we offset the limb from object 2 on the z axis by OFFSET#, OFFSET# changes depending on MOUSEMOVEZ(), so as the user scrolls the limb offsets closer and further away from the object, causing the camera to go with it, giving a zooming ability. There's limits invluced aswell, if OFFSET is less than -500 then it stops zooming out, and if it's greater than -100 then it stops zooming in. Alter the limits and the amountt he camera zooms in, aswell as what axis are changed for different effects. It might be a good idea to alter the Y offset of the limb aswell.

Controls:

- WSAD movement
- Move Mouse to look around
- Use scroll button to zoom in/out

Hope it helps, goodluck.

McChief
20
Years of Service
User Offline
Joined: 24th Mar 2004
Location: USA
Posted: 21st Oct 2005 00:26
RUCCUS,

Awesome! I'll have a look later tonight when I get back home! Thanks for your input.

Login to post a reply

Server time is: 2024-09-24 07:33:18
Your offset time is: 2024-09-24 07:33:18