Page 1 of 1

Broken 3rd Person Camera

Posted: Wed May 09, 2007 3:12 am
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()

Posted: Wed May 09, 2007 10:03 am
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