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 / Fixing the camera to an object + Rotating the object correctly

Author
Message
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 9th Nov 2009 20:23 Edited at: 9th Nov 2009 20:32
Im really stuck on this, ive searched the forums far and wide for an answer to my question, but i cant find one that works for me.

It perplexes me, the camera stays fixed, and it also rotates to the exact angle the object is and never repositions to reflect the angle of the object. Any help?


Pentium 4 2.61ghz 1.5gb DDR 333Mhz RAM NVIDIA GeForce 7600GS AGP 8X
Endangered City. An Endangered Species
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Nov 2009 21:52
Sorry - I've read this 4 times and I still don't understand what you are asking...

Quote: "the camera stays fixed"


Quote: "and it also rotates to the exact angle the object is"


Which is it?

Quote: "and never repositions to reflect the angle of the object"


You just said it does?

Confused am I...

TDK

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 9th Nov 2009 22:02
using the angle of the object and the distance of the camera to the object, use trig to work out the x and z co'ords of the camera.

This is how i do a 3rd person view.

I think that helps

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 10th Nov 2009 19:02
you have to calculate the camera position behind the object ( by a certain amount i.e. -40 in your case ) according to the object position/angle.
DBP commands to do this are newxvalue and newzvalue in relation to the object angle.
Unfortunately turn object does not return the angle from 0 to 360 degrees ( i think it's -90 to +90 )
Therefore it's better to rotate the object according to an angle.
Example:
(remmed code is useless)

Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 10th Nov 2009 19:26 Edited at: 10th Nov 2009 19:28
Whoa whoa whoa whoa.... Thanks for the code, but wow.... I assumed keeping a dynamic camera fixed to an objects back wouldnt need that many lines of code...

UNDEFINED PARSER ERROR when compiling...


Pentium 4 2.61ghz 1.5gb DDR 333Mhz RAM NVIDIA GeForce 7600GS AGP 8X
Endangered City. An Endangered Species
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Nov 2009 19:40
Quote: " that many lines of code..."


LOL!!! there was barely 20 lines in the example provided!!!

If thats too much for you, you could always cheat...

position the camera at the same position as the object, rotate it to the same y angle as the object, then move it backwards 40 units and point it at the object, then sync the screen.




I hope 4 lines of code is not too excessive for you?

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 10th Nov 2009 19:56 Edited at: 10th Nov 2009 21:22
EDIT: Using CodeSurge now. Seems to beat the Parser error
Unfortunately the 4 line cheat doesnt work but the 20 line one works just fine, thanks for that!


Pentium 4 2.61ghz 1.5gb DDR 333Mhz RAM NVIDIA GeForce 7600GS AGP 8X
Endangered City. An Endangered Species
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 13th Nov 2009 12:49
This is two lines...



you put it in a loop with sync, and it keeps the camera behind the object nPlayer, at distance nCamDistance, and at height nCamHeight.

Is that what you wanted to accomplish?

Login to post a reply

Server time is: 2024-11-24 23:31:55
Your offset time is: 2024-11-24 23:31:55