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 Professional Discussion / need help moving camera with object

Author
Message
daniel
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location:
Posted: 12th Oct 2002 22:59
i made a simple little program and the camera will follow my object wherever i go but when the obj turns i want the camera to continuosly point at its back like a chase cam heres my source :

load object "c:\windows\desktop\project\walk.x",1

set object speed 1,50

x=0
y=0
z=0

camx=x-75
camy=50
camz=z-75
pointobj=0

scale object 1,25,25,25
position object 1,x,y,z

make matrix 1,1000.0,1000.0,25,25

position camera camx,camy,camz
point camera 1000,camy,1000

do

camx=object position x(1)
camz=object position z(1)
rotate object 1,0,255+pointobj,0
position camera camx-100,50,camz-100

if upkey()=1 and shiftkey()=1
set object speed 1,85
move object 1,-3
move camera -3
play object 1
endif
if upkey()=1 and shiftkey()=0
set object speed 1,50
move object 1,-1
move camera -1
play object 1
endif
if downkey()=1 and shiftkey()=1
set object speed 1,85
move object 1,3
move camera 3
play object 1
endif
if downkey()=1 and shiftkey()=0
set object speed 1,50
move object 1,1
move camera 1
play object 1
endif
if leftkey()=1 and shiftkey()=1
set object speed 1,85
pointobj=pointobj-3
play object 1
endif
if leftkey()=1 and shiftkey()=0
set object speed 1,50
pointobj=pointobj-1
play object 1
endif
if rightkey()=1 and shiftkey()=1
set object speed 1,85
pointobj=pointobj+3
play object 1
endif
if rightkey()=1 and shiftkey()=0
set object speed 1,85
pointobj=pointobj+1
play object 1
endif
loop
daniel
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location:
Posted: 12th Oct 2002 23:01
im a little sloppy on my coding tho =(

Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 00:23
Okay, without even really reading what you have there, I can answer this one. Move the object around however you like, then set camera to object orientation, then position camera object position x,y,z, then move camera backwards however much you want. If you want the camera to be slightly above, or below, then just offset the y position slightly and if you still want it to look directly at the center of your object, just point object. You could also look at the set camera to follow command in the cameras section of the help file, though I've never actually tried using that, so I'm not sure if it will do what you want.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
daniel
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location:
Posted: 13th Oct 2002 17:14
that does the exact same thing as my code does. the only difference is if you use my code instead of the object orientation command the camera is not as ruff when walking around. it still does not rotate around the object like a chase cam tho =(

Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 18:56
Okay, the set camera to object orientation command doesn't work right now. Try modifying this code:


System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
Andy Igoe
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 15th Oct 2002 01:47
position camera object position x(1),object position y(1)+height,object position z(1)
rotate camera object angle x(1),object angle y(1),object angle z(1)
move camera -distance

where height & distance are numbers relative to your world size.

Pneumatic of Xev@EQ
System Specs: 2Ghz; 512mb; 80gb; Tnt2; 17"/15" Dual Head; Video I/O; 2xPAL Video & 14" 25Hz Monitor
BotPC: 800Mhz; 512mb; 4gb; GeForce2; 17"

Login to post a reply

Server time is: 2024-04-20 08:05:28
Your offset time is: 2024-04-20 08:05:28