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.

3 Dimensional Chat / Camera/Character Control

Author
Message
HyTech Designs Sam
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Canada
Posted: 27th Nov 2003 04:30 Edited at: 27th Nov 2003 04:32
Hi, I am making a 3rd person action/adventure game in Dark Basic. I have a few questions about my code for camera/character control.

This is the code I currently have written:
Character Control:


Camera Control:


So, my question is, how can I "attach" the camera to the character, right now the character moves but the camera stays in one spot. I would like to be able to have the camera follow the character when the player uses the arrow keys to move but when they use the mouse the camera moves around the character.
My second question is, how can I make it so that the charater goes up and down with the height of the matrix, right now it just goes right through the hills.

Thank you and I how that I explain myself well enough. Thanks again in advance for any help.

-Sam
walaber
21
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 27th Nov 2003 04:39
looking at your code, it looks like your camera rotates around the point 500,50,500 (i didn't look too close)... but I would think that if you simply replace these values with object position x(1), object position y(1),etc <-the object you are moving in the movement code... this should rotate the camera around the current position of the object...

however I think it would be a good idea to make some variables for your charaxter's position. for example...

Playerx Playery Playerz
then use your movement code like this:
if upkey()=1 then inc playerz,1
etc

then at the end, just add
position object 1,Playerx,Playery,Playerz

then you can also position the camera based on these variables (instead of using object position functions)

also I like to make a TYPE for my 3D positions... for example

TYPE ThreeDPoint
x as float
y as float
z as float
ENDTYPE

PlayerPos as ThreeDPoint

PlayerPos.x = 10
PlayerPos.y = 100
PlayerPos.z = 0

etc...

okay I've rambled enough (I'm bored at work)

good luck!

Go Go Gadget DBPRO!
HyTech Designs Sam
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Canada
Posted: 27th Nov 2003 04:45
Quote: "I'm bored at work)"
know the feeling

anywho Thank You very much, I'll try what you suggested.

-Sam
Clarks
21
Years of Service
User Offline
Joined: 30th Oct 2003
Location: BALTIMORE,MARYLAND
Posted: 27th Nov 2003 09:41
Listen up S-A-M you dont have to use none of that sin, cos and tan crap to position the camera behind the player. Didn't you read the manual. Use newxvalue, newyvalue, and newzvalue commands. Trust me it makes life easier.


return value = newxvalue(current position, current angle, step value)
cpx#=newxvalue(px#,ay#-180,10)
cpz#=newzvalue(pz#,ay#-180,10)

assume px# and pz# are the players x and z positions, ay# is player angle y.

if you want the player to move according to matrix height use the get ground height command

return value = get groud height(matrix number, x position, z position)

if you want to use the mouse to rotate the camera around the player, you can use variables with newvalues command.

return value = newxvalue(current position, current angle, step value)
add a variable to current angle thats gonna increase and decrease according to mouse movement to change the angle at which the camera is positioned.
add a variable to step value thats gonna change with mouse movement to act like the cameras radius around your player object.

i'll post some lines of code to show you but i have something to do so i'll post it later unless somebody beats me to it.
HyTech Designs Sam
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Canada
Posted: 27th Nov 2003 15:20
ok thanks, I have not read the manuel because as of right now I am working with the demo version, I am purchasing it soon, maybe I would have figured it out then . Thanks anyway

-Sam

Login to post a reply

Server time is: 2025-05-14 09:50:28
Your offset time is: 2025-05-14 09:50:28