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 / How do you create a 3rd person camera?

Author
Message
Dark FLAS
21
Years of Service
User Offline
Joined: 18th Sep 2002
Location:
Posted: 22nd Sep 2002 01:57
Ive always wanted to create a 3rd person game for example "a raceing game, FPS game etc" i can get most of the code right but when it comes to the camera i mess it all up if any one could help me then email me on
cottrel499@yahoo.co.uk
if you cant well thank you for reading this

PS - I have only got dark basic pro i think it is much better than darkbasic it has lot more stuff in it-
I will code your ass!!
Dark FLAS
21
Years of Service
User Offline
Joined: 18th Sep 2002
Location:
Posted: 22nd Sep 2002 02:00
Opes i posted two sorry

I will code your ass!!
Super Teo
21
Years of Service
User Offline
Joined: 18th Sep 2002
Location: Sweden
Posted: 22nd Sep 2002 21:45
This is Actually from Dark Basic, help files. Hope it helps.

Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 3rd Dec 2002 12:01
Here is a good way to implement 3rd person cameras

sync on
sync rate 0

make object sphere 1,50


do

Rem Get object angle
oby#= object angle y(1)

Rem allow object to respond to keypresses

if upkey()=1 then move object 1,10
if leftkey()=1 then yrotate object 1,wrapvalue(oby#-5)
if rightkey()=1 then yrotate object 1,wrapvalue(oby#+5)

obpx#= object position x(1)
obpz#= object position z(1)

Rem position object at these co-ordinates

position object 1,obpx#,0,obpz#

Rem Using the newxvalue and newzvalue functions, work out a
Rem camera position based upon objects location i.e. 100 Rem world units away and slightly above.

camx#= newxvalue(obpx#,oby#-180,50)
camz#= newzvalue(obpz#,oby#-180,50)

position camera camx#,100,camz#

rem point camera at object

point camera obpx#,0,obpz#

rem refresh screen and loop
sync
loop



This code works on any size object. You need to know the size of the object and make sure that the camera is positioned always twice the size above the object and that the newvalues are worked out based upon the size of the object i.e. nexvalue(objectposition,angle,objectsize).

Hope the code was helpful to you

TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 3rd Dec 2002 13:05
Why not use the "Set Camera To Follow"-command.
Not sure if it exist in DBPro. But it works in DBC.
This will generate a smooth camera rotation effect, with configurable smoothness and distance to object.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Epidemicz
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 3rd Dec 2002 23:39
Well if you wanted to make a 3rd person game you wouldn't want to make a first person shooter(FPS)lol.

I am the very disease you pretend to be.

Login to post a reply

Server time is: 2024-04-24 23:38:48
Your offset time is: 2024-04-24 23:38:48