Hi,
I am new to Blitz and have been playing for the last 2 days trying to get something roughly cobbled together from example code which comes with it, so Ican have something to build an idea upon.
I basicaly have a spaceship flying around a randomly created asteriod field where the camera is always directly behind the ship regardless of which of the three axis it moves in. This code was taken from the xpilot demo and re-worked a bit to make it do what I wanted (and follow the ship in the y axis movement which the xpilot demo didn't do).
All fine so far. But when the ship moves in the y (up/down) axis I want there to be a little lag so the camera follows and turns about 1 or 2 seconds behind the ship (which currenttly happens when the ship banks in the z axis and then turns). But I have no real idea who to introduce that time lag.
The code I use at the moment for controling the ship & camera is :
As I said this is mostly from the xpilot demo. Can someone tell where I should be looking for the time-lag part. I do not expect the answer, just an idea of where to look and what for so I can try and find the solution as I did with getting the camera to rotate on the x axis (up/down) with the ship so it always behind it.
I hope that made some sense of what I am trying to acheive and understand.
Thanks
Max
I am new to Blitz and have been playing for the last 2 days trying to get something roughly cobbled together from example code which comes with it, so Ican have something to build an idea upon.
I basicaly have a spaceship flying around a randomly created asteriod field where the camera is always directly behind the ship regardless of which of the three axis it moves in. This code was taken from the xpilot demo and re-worked a bit to make it do what I wanted (and follow the ship in the y axis movement which the xpilot demo didn't do).
All fine so far. But when the ship moves in the y (up/down) axis I want there to be a little lag so the camera follows and turns about 1 or 2 seconds behind the ship (which currenttly happens when the ship banks in the z axis and then turns). But I have no real idea who to introduce that time lag.
The code I use at the moment for controling the ship & camera is :
Local x_dir,y_dir,z_dir If KeyDown(203) x_dir=-1 If KeyDown(205) x_dir=1 If KeyDown(200) y_dir=-1 If KeyDown(208) y_dir=1 If KeyDown(30) z_dir=1 If KeyDown(44) z_dir=-1 If KeyHit(59) p\cam_mode=1 If KeyHit(60) p\cam_mode=2 If KeyHit(61) p\cam_mode=3 If KeyHit(62) p\cam_mode=4 If x_dir<0 p\yaw_speed=p\yaw_speed + (4-p\yaw_speed)*.04 Else If x_dir>0 p\yaw_speed=p\yaw_speed + (-4-p\yaw_speed)*.04 Else p\yaw_speed=p\yaw_speed + (-p\yaw_speed)*.02 EndIf If y_dir<0 p\pitch_speed=p\pitch_speed + (2-p\pitch_speed)*.2 Else If y_dir>0 p\pitch_speed=p\pitch_speed + (-2-p\pitch_speed)*.2 Else p\pitch_speed=p\pitch_speed + (-p\pitch_speed)*.1 EndIf p\yaw=p\yaw+p\yaw_speed If p\yaw<-180 Then p\yaw=p\yaw+360 If p\yaw>=180 Then p\yaw=p\yaw-360 p\pitch=p\pitch+p\pitch_speed If p\pitch<-180 Then p\pitch=p\pitch+360 If p\pitch>=180 Then p\pitch=p\pitch-360 p\roll=p\yaw_speed*30 RotateEntity p\entity,p\pitch,p\yaw,p\roll ;see if y/p/r funcs are working... t_p#=EntityPitch( p\entity ) t_y#=EntityYaw( p\entity ) t_r#=EntityRoll( p\entity ) RotateEntity p\entity,t_p,t_y,t_r If p\ignition If z_dir>0 ;faster? p\thrust=p\thrust + (20-p\thrust)*.04 ;1.5 Else If z_dir<0 ;slower? p\thrust=p\thrust + (-p\thrust)*.04 EndIf MoveEntity p\entity,0,0,p\thrust Else If z_dir>0 p\ignition=True EndIf EntityParent p\camera,p\entity RotateEntity p\camera,p\pitch,p\yaw,p\roll,True PositionEntity p\camera,EntityX(p\entity),EntityY(p\entity),EntityZ(p\entity),True MoveEntity p\camera,0,1,-5 PointEntity p\camera,p\entity,p\roll/2
As I said this is mostly from the xpilot demo. Can someone tell where I should be looking for the time-lag part. I do not expect the answer, just an idea of where to look and what for so I can try and find the solution as I did with getting the camera to rotate on the x axis (up/down) with the ship so it always behind it.
I hope that made some sense of what I am trying to acheive and understand.
Thanks
Max