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 / 3rd person camera that remains behind ship

Author
Message
MatriX
21
Years of Service
User Offline
Joined: 19th Oct 2003
Location: Deer Park, New York
Posted: 27th Dec 2008 21:02
I'm using newx,y and z value command (newxvalue etc.) to determine a point in space behind my ship.

When the ship rotates however those values don't actually follow the ship's axis (orientation.) It just remains at the offset position in space according to the world.

I think I need to match the ship's orientation not the world's orientation. Hmm. Any thoughs? I'm missing something key here.

Ship is object 400:



Thanks in advance...

Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 28th Dec 2008 00:35
I might be misunderstanding the problem, but you want to keep the camera 300 units behind the ship horizontally and 50 units above it vertically in the direction the ship is facing, right?

I tried out the code segment you posted, and found that it got the camera to stay behind the ship but didn't move up or down with it as it should've when the ship rotated on its X axis.

I've never been a fan of the newxvalue, etc. commands. I managed to solve the problem by thinking it all out with trig and now have no idea how I would translate my solution into newxvalue, etc. commands. So, I wrote a little example using free flight motion on a box.



I hope this is the kind of thing you were looking for. The trig might be a little long and convoluted but I'd be more than willing to explain it all step by step if you want me to.

Another thought: This motion might be a little sudden, or jerky. I suppose it's easy enough to use the curvevalue command on the three camera position variables to get smoother camera...
MatriX
21
Years of Service
User Offline
Joined: 19th Oct 2003
Location: Deer Park, New York
Posted: 28th Dec 2008 02:04
Thanks Kira. This is exactly what I was looking for. I only wish I was good with trig like that

I'm going to dissect it and figure it out. You don't need to explain any further.

Thanks again!

Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 28th Dec 2008 05:07
You are most certainly welcome. Glad I could help.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 12th Jan 2009 02:55
Hey, I know it's been a while, but I took another look at this stuff and wrote two functions that might prove useful for to do the same thing.

Here they are if you're still interested:



CameraFollowObject(Camera,Object,FollowX#,FollowY#,FollowZ#,XAng#,Yang#,ZAng#)
This command makes a camera follow an object at a certain distance while turned a certain way.
Camera - The camera you want to use
Object - The object to follow
FollowX#,FollowY#,FollowZ# - The distances between the camera and object
XAng#,YAng#,ZAng# - The angles to add to the object's orientation

OrbitCamera(Camera,Object,XDist#,YDist#,ZDist#,XAng#,YAng#,ZAng#,ZDepthFlag)
This command sticks an object in a camera's view regardless of orientation and position. It works like lock object on, but the object moves with the camera as opposed to sitting still near the origin.
Camera - The camera to lock the object on
Object - The object to lock in the view
XDist#,YDist#,ZDist# - The object's distances from the camera
XAng#,YAng#,ZAng# - The object's rotation in the camera's view
ZDepthFlag - Set to 0 if you want to disable the object's Z depth

Maybe these'll help in some way.
MatriX
21
Years of Service
User Offline
Joined: 19th Oct 2003
Location: Deer Park, New York
Posted: 12th Jan 2009 04:08
Omg I was just working on something like that! Very nice. I will definitley check them out and post back whatever it is that I came up with as well.

Thanks

Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Long Island Amateur Game Development Group http://www.meetup.com/LIAGDG/
MatriX
21
Years of Service
User Offline
Joined: 19th Oct 2003
Location: Deer Park, New York
Posted: 12th Jan 2009 05:05
Sometimes I want to bang my head against the wall because I can't even really figure out what it is I'm trying to accomplish lol.

Anyhow - take a look at this. It orbit pans with the arrow keys or the mouse (RTS style) as it moves near the edge of the screen.





This works kind of with a dummy object that rotates and a main cube that is static. (I know I'm sloppy ) (There is also a blue object that represents the camera.)

I'm getting confusted trying to figure out what should actually happen in the ship were rotating. I guess the orbit position should remain the same but the camera should rotate with the ship so that it remains in the same offset position.

I'm going to experiment with your code now. You've been a great help thus far. Can't thank you enough.

Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Long Island Amateur Game Development Group http://www.meetup.com/LIAGDG/

Login to post a reply

Server time is: 2024-11-24 14:33:25
Your offset time is: 2024-11-24 14:33:25