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 Discussion / 3rd person camera

Author
Message
Binary Coder
18
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 7th Apr 2007 06:12
Hi,
I was just wondering if anyone could help me find an error in this code.

sync on
make matrix 1,500,500,5,5
load object "sonic head.x",1
yrotate object 1,180
a#=0
do
if upkey()=1 then move object 1,3
if downkey()=1 then move object 1,-3
if leftkey() then turn object left 1,5:dec ang,2
if rightkey() then turn object right 1,5:inc ang,2
ang=wrapvalue(ang)
set camera to follow object position x(1),object position y(1),object position z(1),ang,200,3,10,0
position object 1,ox#,oy#,oz#
sync
loop


The camera was supposed to follow behind the object whitch it did perrety well. But it seems that when i rotate the object it dosent follow behind (for a third person game). Also the matrix seems to move with it or that the object it is not moving at all.

Thank you
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Apr 2007 16:10 Edited at: 7th Apr 2007 16:35
Try this:



Get rid of everything you have that is in your post between:

do

sync
loop

and put what I have.

You have to track all x,y,z coordinates of the object so you know where the object is so the camera can follow it. You also track everything for the camera. So if you move forward, backwards, turn left or right the camera will follow.

I believe I have it commented well enough so you can understand what the code is doing. You may have to change the variable names or the coordinates to get it just the way you want it to look, but this is straight out out my program. Hope this helps.

Any questions just ask.

3.0 Ghtz/1GB DDR400 Ram/Ati 9550 256MB AGP Graphics/100GB Maxtor Sata Drive/Dark Basic Pro 6.5

Know one cares how much you know until they know how much you care.
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 7th Apr 2007 16:16
perhaps instead of turn object left, look into yrotate object and give it a rotate value of wrapvalue(object angle y(1) - 5)

and then, instead of set camera to follow.
try positioning the camera at object 1's position, then moving the camera back, say 5 units...

as for the matrix moving, no commands there should be moving the position of a matrix... The object doesn't seem to move, because whenever you press forward, you move the object forward, and then immediately undo that by positioning object 1 at ox# oy# and oz# -- none of these values are being updated during the loop...
Binary Coder
18
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 8th Apr 2007 08:17
Thanks Guys!!
It now works well.

Now I was wondering how to set collision for my object and enemy (but only when the attack anim is playing)


Thank you for your awnsers!


Binary Coder
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 8th Apr 2007 15:41
Try looking here. All this has to do with collision.

http://forum.thegamecreators.com/?m=forum_view&t=95770&b=7

3.0 Ghtz/1GB DDR400 Ram/Ati 9550 256MB AGP Graphics/100GB Maxtor Sata Drive/Dark Basic Pro 6.5

Know one cares how much you know until they know how much you care.
Binary Coder
18
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 9th Apr 2007 12:27
Thanks again Unseen Ghost!
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 10th Apr 2007 03:16
Your welcome, glad I could help.

3.0 Ghtz/1GB DDR400 Ram/Ati 9550 256MB AGP Graphics/100GB Maxtor Sata Drive/Dark Basic Pro 6.5

Know one cares how much you know until they know how much you care.

Login to post a reply

Server time is: 2025-05-27 19:39:01
Your offset time is: 2025-05-27 19:39:01