I'm using a keyboard movement system, not a mouse, but here is how I do a strafe. I created a pivot for my camera, naming it "pcam". Movement operations are done to the pivot pcam, and the camera follows along for the ride.
As you can see, I create a "strafe" condition, and activate based on whether someone is pressing an ALT key (either one). Works like a charm.
(Hmm, upon looking at my code, it occurs to me that I never initialize "cam_y", so I'll have to fix that.)
strafe=False:dir#=0 If KeyDown(205) ;turn right If KeyDown(56) Or KeyDown(184) ;either ALT key strafe=True dir=0.1 Else cam_y=cam_y-2 EndIf Else If KeyDown(203) ;turn left If KeyDown(56) Or KeyDown(184) ;either ALT key strafe=True dir=-0.1 Else cam_y=cam_y+2 EndIf EndIf cam_z#=0 If KeyDown(200) ;Up arrow, go forward If KeyDown(42) Or KeyDown(54) ;either Shift key cam_z = .3 ;running Else cam_z = .1 EndIf Else If KeyDown(208) ;Down arrow, go back If KeyDown(42) Or KeyDown(54) ;either Shift key cam_z = -.3 ;running Else cam_z = -.1 EndIf EndIf If strafe MoveEntity pcam,dir,0,0 ;go left or right Else RotateEntity pcam,0,cam_y,0 ;turn to left or right MoveEntity pcam,0,0,cam_z ;go foward or back EndIf FlushKeys Collisions 1,2,2,2 ;Camera collision with objects, slide from point of collision UpdateWorld RenderWorld
As you can see, I create a "strafe" condition, and activate based on whether someone is pressing an ALT key (either one). Works like a charm.
(Hmm, upon looking at my code, it occurs to me that I never initialize "cam_y", so I'll have to fix that.)