iDevGames Forums
Camera Following Object (3rd Person Perspective) - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Camera Following Object (3rd Person Perspective) (/thread-6619.html)

Camera Following Object (3rd Person Perspective) - squidgee - Nov 30, 2003 09:53 AM

Alrighty, in RB3D, I want my camera to follow my player object(3D).

So, when my player object moves (the yaw changes, and it goes off wherever), how do I make it so the camera stays X units behind it at all times (and, X units above it)?

I'm kinda foggy on how to do it; I know it must have something with setrotateaboutaxis, but I'm not sure how to do it...any code/examples will be much appreciated!

player.goforeward 10
[What goes here to make the camera stay behind it???]

Camera Following Object (3rd Person Perspective) - ERaZer - Nov 30, 2003 11:58 AM

Hmm, ok.
I just added this code to the offworld project, so it should work

qcam =
qcam.x = mShipState.mObject3D.orientation.x
qcam.y = mShipState.mObject3D.orientation.y
qcam.z = mShipState.mObject3D.orientation.z
qcam.w = mShipState.mObject3D.orientation.w

campos =
v = mShipState.mObject3D.position
campos.x = v.x
campos.z = v.z
campos.y = v.y
View.Camera.MoveForward -175

Hmm, I just realised you could probably use campos.Copy v instead, but I don't know since that command has been added(or at least I didn't know of it) when I used RB3D.

mShipState.mObject3D is the players object3d and view is the RB3DSpace.

Oh, and MoveUp is a method to move a object3D up that I've added. I think I took it from Franks 3D sound example.