Topic: Camera Trouble
Hi gman, I have a strange problem with my camera since v1.3, I can't figure out why.
My camera code worked with v1.2, I hadn't changed anything since.
The camera should follow the player from behind, but now it only stays in the center of the screen no matter what vector the position is and seems to rotate weird. Also it seems to clip object much closer that it's supposed to. I cant see the player if he moves forward and I can't see some of the objects that should be in the scene.
I think it may have something to do with the matrices or just the camera. I also think it could be a problem from my second scene manager.
'Update Player
Local M1:Matrix4 = Matrix4.create()
Local M2:Matrix4 = Matrix4.create()
Local Rot:Vector3df = Momentum
PlayerNode.updateAbsolutePosition()
M1.setRotationDegrees( PlayerNode.GetRotation())
M2.setRotationDegrees( Rot )
M1.MultEq( M2 )
PlayerNode.SetRotation( M1.getRotationDegrees())
PlayerNode.setPosition( PlayerNode.getAbsolutePosition().Plus( Velocity ))
PlayerNode.updateAbsolutePosition()
M1.Destroy()
M2.Destroy()
'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 )
Offset.PlusEq( PlayerNode.getPosition())
CAMERA.setPosition( OffSet )
CAMERA.setUpVector( UP )
OffSet.PlusEq( Forward )
CAMERA.setTarget( OffSet )
CAMERA.updateAbsolutePosition()
M3.Destroy()
I could post more code, but there's a lot.