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 / A few problems i ran into(camera and range finding)

Author
Message
FPSC Scripts
18
Years of Service
User Offline
Joined: 2nd Oct 2006
Location: Curacao
Posted: 7th Jul 2007 18:26
Hi all, i was practising my darkbasic skills but i ran into a few problems and i try to solve them but no luck, my problems are below:
1.How do i make my camera look behind the player object, for example in car racing games you can look behind you to see if any thing is coming, how do i do this i try'd this code:

But it wont look backwards and when i release 1 the camera stays rotated,so i wanna know how do i make my camera look backwards/behind when i press a key(for example1) and when i release the key it will go back to the position before i pressed for example 1
2.How do i make my object do something when its in range,for example a range of 500.

i'm the M king.
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 7th Jul 2007 20:05 Edited at: 7th Jul 2007 20:15
1)
if cay# is your camera angle:
......
if keystate(2)=1 then cay#=wrapvalue(cay#+180.0)
yrotate camera cay#
.....

2)
xdiff#=object position x(player)-object position x(other object)
zdiff#=object position z(player)-object position z(other object)
distance#=sqrt(xdiff#*xdiff#+zdiff#*zdiff#)
if distance#<500.0 then do something
FPSC Scripts
18
Years of Service
User Offline
Joined: 2nd Oct 2006
Location: Curacao
Posted: 7th Jul 2007 23:27
Thanks,but at the first one the camera doesn't aways get behind the ship,but atleast it works

i'm the M king.
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 7th Jul 2007 23:51
Depends on how you handle the forward camera look, it's hard to find a solution from an example based on a line of code

Login to post a reply

Server time is: 2024-11-25 15:28:42
Your offset time is: 2024-11-25 15:28:42