Camera Following Object (3rd Person Perspective)
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!
(e.g
player.yaw(0.1)
player.goforeward 10
[What goes here to make the camera stay behind it???]
)
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!
(e.g
player.yaw(0.1)
player.goforeward 10
[What goes here to make the camera stay behind it???]
)
Hmm, ok.
I just added this code to the offworld project, so it should work
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.
I just added this code to the offworld project, so it should work
Code:
qcam = View.camera.orientation
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 = View.camera.position
v = mShipState.mObject3D.position
campos.x = v.x
campos.z = v.z
campos.y = v.y
View.Camera.MoveForward -175
View.Camera.MoveUp(50)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.
"Gameplay Uber Alles. And if you can make it psychedelic too, great!" - Jeff Minter
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| How do I apply a perspective transform to a UIView and add to cocos2d | sefiroths | 0 | 1,901 |
Sep 24, 2012 05:45 AM Last Post: sefiroths |
|
| Switching To Third Person | Nick | 9 | 4,440 |
Mar 31, 2005 12:14 AM Last Post: lpetrich |
|
| First Person Shooter | Nick | 14 | 6,234 |
Mar 19, 2005 04:26 PM Last Post: Frank C. |
|

