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 / camera follow an object?

Author
Message
scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 00:12
im pretty new to "coding" just wondering if any one can post some code to make a camera follow an object that moves, but the camera stays at the same level/angle. (and how do u make camera turn left if the object turns left) this is what i have so far:
[code
sync on
sync rate 140
make object cube 1,1
make camera 1
position camera 1,0,5,0
point camera 1,0,0,0
do
if upkey()=1 then move object 1,.1
if downkey()=1 then move object 1,-.1
if leftkey()=1 then turn object left 1,5
if rightkey()=1 then turn object right 1,5
sync
loop]
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 9th Apr 2010 00:18
If you have IanM's plugins, you can use this code to control object 1.



Don't use camera 1, use camera 0 and I would advise lowering the sync rate to 60 or 70, 140 just seems too fast.

Rawwrr. Sig Fail.
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 9th Apr 2010 00:22 Edited at: 9th Apr 2010 00:23
I've been using "set camera to follow object" for part of my camera function in my game, though I'm not sure if I'll be keeping it as my camera code is only a rough setup at the moment. It might work for you though.
scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 00:33
thanks a lot but,what is IanM's plugins. and the code didnt work for me: "move camera UP 1" wasnt a code.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 9th Apr 2010 00:37
They're a collection of commands. move camera up is one of them

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18&msg=1972494#m1972494

Rawwrr. Sig Fail.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Apr 2010 00:39
Also look at:

set camera to follow x#,y#,z#,angle#,distance#,height#,smooth#,flag

TheComet

scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 00:40
i only have pitch camera up, but when i use that the game just ends instantly and NickH "set camera to follow" isnt working?
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 9th Apr 2010 00:49
I don't see why pitch camera up would end the game... But download the files from the link I gave you, and you can use the move camera up command.

Rawwrr. Sig Fail.
scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 00:50
nevermind i think ill just use : control camera using arrowkeys 1,.1,1
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Apr 2010 00:54 Edited at: 9th Apr 2010 00:55


TheComet

NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 9th Apr 2010 01:00
Quote: ""set camera to follow object""

Hehe I just realised when I copied and pasted my last post i pasted it wrong, I just noticed as written above it's "set camera to follow". This seems to work well enough.
scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 01:02
thanks a lot thecomet, and will do madnightmare. thanks everyone
scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 01:06
p.s. how do you get things into that "code snippet"?
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 9th Apr 2010 01:12
When you post, theres options along the top, the one furthest to the right says 'code'.

Highlight the code, the click that.

Rawwrr. Sig Fail.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Apr 2010 12:06
Your post should look like this after pressing the code button:

[ code ] Your code goes here [ /code ]

And if you want the different commands to be colored like here


Then replace [ code ] with [ code lang=dbp ].

TheComet

scuzz
16
Years of Service
User Offline
Joined: 27th Mar 2010
Location:
Posted: 9th Apr 2010 18:45
so i cant use "move arrowkeys to move camera" because when it hits the wall, the box stops, while the camera keeps going. thecomet, your code works well except the camera wont follow the cube when it turns all the way around (360 degrees) ???

Login to post a reply

Server time is: 2026-07-26 15:31:32
Your offset time is: 2026-07-26 15:31:32