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 / can't get the camera to follow right

Author
Message
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 8th Apr 2003 22:16
when i move the up arrow key, my object moves to the left (increasing my z coordinate instead of my x) what am i doing wrong?

player object :


movement control


thanx in advance to anyone
You're ate up like a soup sandwich.
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 8th Apr 2003 23:47
make object box 900,50,50,50
set object collision on 900
`hide object 900
position object 900,2689,0,2409
x# = object position x(900)
z# = object position z(900)
y# = get ground height(1,x#,z#)

do
x#=newxvalue(x#,a#,s#)
z#=newzvalue(z#,a#,s#)
y#=get ground height(1,x#,z#)
position object 900,x#,y#+5,z#
yrotate object 900,a#
if upkey()=1 and s#<12 then s#=s#+2
if downkey()=1 and s#>-12 then s#=s#-2
if leftkey()=1 then a#=wrapvalue(a#-4)
if rightkey()=1 then a#=wrapvalue(a#+4)
gosub update_camera
sync
loop
update_camera:
rem Position camera to the back of the character
cx#=newxvalue(x#,wrapvalue(a#),-300)
cz#=newzvalue(z#,wrapvalue(a#),-300)
cy#=get ground height(1,x#,z#)
position camera cx#,cy#+25,cz#
rem Point camera at object
point camera x#,y#,z#
return
Engulfed by Darkness
21
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 8th Apr 2003 23:48
Your object is moves fine. It moves in the direction that it is facing in.
Your problem is that your camera is positioned to the left of your object.

Change:
cameraz# = newzvalue(z#,AngleY#-100,100)
camerax# = newxvalue(x#,AngleY#-100,100)

To:
cameraz# = newzvalue(z#,AngleY#-180,100)
camerax# = newxvalue(x#,AngleY#-180,100)

This will position the camera behind your object.
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 9th Apr 2003 00:28
yeah, i just now found my mistake about the 180 degree thing. i want the camera to follow the object closer, i tried the set camera to follow command but the camera would just go straight through the matrix when following the object. going to try scorpyio's code to see how that works.

You're ate up like a soup sandwich.
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 9th Apr 2003 00:32
that code goes straight through the matrix also.

You're ate up like a soup sandwich.
Engulfed by Darkness
21
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 9th Apr 2003 05:20
Use the code that i pasted in "Moving over a landscape".
It works. I've tested it. It doesn't go through the matrix.
Just change the "Load image "twigs02.bmp",1" to what ever texture you have in the same directory as the code.
Engulfed by Darkness
21
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 9th Apr 2003 05:23
Or better yet go to [href]www.darkbasic.com[/href]. Then click on the create tab at the top. Then find the online 3d tutorials and start reading.
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 9th Apr 2003 05:39
thanx, how do i get the camera closer to the object, better yet, how do i get the camera on top of the object?

You're ate up like a soup sandwich.
Engulfed by Darkness
21
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 9th Apr 2003 06:10
To get the camera closer:

cameraz# = newzvalue(z#,AngleY#-180,100)
camerax# = newxvalue(x#,AngleY#-180,100)

Make the bold number smaller to bring camera in towards object.

If your going to have the camera right on top of the object do you want to see the object??? If not then you don't really need the object at all. Just move the camera around with the arrow keys.

Ex.
Do

cYang# = camera angle y()

If upkey()=1 then move camera 5
If downkey()=1 then move camera -5
If leftkey()=1 then yrotate camera wrapvalue(cYang#-5)
If rightkey()=1 then yrotate camera wrapvalue(cYang#+5)

Loop
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 9th Apr 2003 06:15
i need the object for collision, i tried making those values smaller but it kept making the camera look down on the object instead of ahead.

You're ate up like a soup sandwich.
Engulfed by Darkness
21
Years of Service
User Offline
Joined: 31st Mar 2003
Location: Canada
Posted: 9th Apr 2003 06:57
Is there a POINT CAMERA x,y,z command in your code???
I bet there is.

Try increasing the "y" value in that command.
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 9th Apr 2003 19:36
point camera x#,y#+value,z#

Login to post a reply

Server time is: 2024-09-20 03:41:15
Your offset time is: 2024-09-20 03:41:15