Broken 3rd Person Camera

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
HondaDarrell
Posts: 20
Joined: Sun Aug 27, 2006 9:10 pm
Location: U.S.A.
Contact:

Broken 3rd Person Camera

Post by HondaDarrell »

I've been working with arras's cockpit camera function.
I had modified the code for a 3rd person game and had it working. About a month ago I had switched to v1.3 and changed some code, now the camera is in the wrong position and doesn't seem to follow the player.
I'm using the blitzMax language with an irrlicht wrapper.
Would my code cause a problem like this?

Here's a build of the game.
controls are W, A, S, D, Q, E, and Space.

Here's the player movement and camera code.

Code: Select all

'Update Player
Local M1:Matrix4 = Matrix4.create()
Local M2:Matrix4 = Matrix4.create()
Local Rot:Vector3df = Inertia

PlayerNode.updateAbsolutePosition()
M1.setRotationDegrees( PlayerNode.GetRotation())
M2.setRotationDegrees( Rot )
M1.MultEq( M2 )
PlayerNode.SetRotation( M1.getRotationDegrees())
PlayerNode.setPosition( PlayerNode.getPosition().Plus( Velocity ))
PlayerNode.updateAbsolutePosition()

'Update Camera
Local M3:Matrix4 = Matrix4.create()
Local Forward:Vector3df = _VECTOR3DF( 0, 0, 1 )
Local Up:Vector3df = _VECTOR3DF( 0, 1, 0 )
Local OffSet:Vector3df = _VECTOR3DF( 0, 5, 15 )

M3.setRotationDegrees( PlayerNode.GetRotation())
M3.transformVect( Forward )
M3.transformVect( Up )
M3.transformVect( OffSet )
Cam.setTarget( PlayerNode.getPosition().Plus( Forward ))
Cam.setUpVector( Up )
Cam.setPosition( PlayerNode.getPosition().Plus( OffSet ))
Cam.updateAbsolutePosition()
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

i guess u shouldn't transform the up vector........but well it's a flight game....maybe only transform the up vector by one axis and not all three
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply