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.

DarkBASIC Discussion / 3rd Person Mouse Control

Author
Message
bobhoil
16
Years of Service
User Offline
Joined: 28th Mar 2009
Location:
Posted: 28th Mar 2009 19:17
Hey everyone I am new to DarkBasic and am currently working on a game. Right now I have a character controlled be using the arrow keys to move and it is in 3rd person perspective. I was wondering how I can use the mouse to change the direction of the camera and mouse instead of just using the left and right arrow keys!

Thanks,
Bob Hoil

http://bobhoil.com/
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 28th Mar 2009 21:45
There are several ways. There is the SET CAMERA TO FOLLOW command which includes and angle arguments. I can't explain the command very well, as I have only gotten it to work the way I need it to on a couple occasions on account of not understanding it. However, TDK wrote a tutorial on it and it is VERY well written. It helped me understand it (then I forgot since I didn't use it).


Another way, which is one I have used many times and has worked is as follows:

Each time through the loop you position the camera at the player's position, orientate it to the objects orientation (SET CAMERA TO OBJECT ORIENTATION), turn it the appropriate angles (left and right), pitch it the appropriate angles (up and down), then move it backwards a fixed distance (play with it, use the MOVE OBJECT and a negative number to move it back). This can be done with TURN CAMERA RIGHT and PITCH CAMERA UP. You must to it in this order though, if you pitch then turn, you will get weird camera angles (not good).

To keep track of the turn values, you can add the MouseMoveX() and MouseMoveY() values (it could be subtract but play with it till it works).

I will see if I can find some old code of mine that used this and try to get it to you, but does this make sense how to do it?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
bobhoil
16
Years of Service
User Offline
Joined: 28th Mar 2009
Location:
Posted: 28th Mar 2009 22:34
Yea I think I can understand what you are saying... so if I have the camera follow the character can I just position the characters direction with the mouse?

http://bobhoil.com/
bobhoil
16
Years of Service
User Offline
Joined: 28th Mar 2009
Location:
Posted: 2nd Apr 2009 02:19
I was wondering if I could get a little more help on this subject! Maybe just a few pointers or something.. I have tried a few things but sadly I think I am lost.. I have restarted and am now trying to edit the code from the third person example to make direction mouse controlled.

http://bobhoil.com/

Login to post a reply

Server time is: 2025-08-08 20:42:38
Your offset time is: 2025-08-08 20:42:38