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()