Hi RiverRatt, thanks for replying. The easiest thing to do is to copy and paste the following code:
This is Viperfish code, now when you run that, bearing in mind to add your own texture and ship, if you click on left cursor, you will see the ship rolls to the left. What I want to achieve is to make the ship turn left, basically bank left. (Hope that makes some sort of sense?)
I have checked the sample xfighter.bb code which Matty had programmed in Blitz3d, but couldn't see a way of adapting that to this code
Any help would be greatly appreciated :)
Graphics3D 1024,768,16,1 SetBuffer BackBuffer() Const climbspeed# = 1, rollspeed# = 2 Global xrotation#,zrotation#,speed# Global camera% = CreateCamera() Global plane% = CreatePlane() Global planetex% = LoadTexture("planettextures/ground4.bmp");Replace with your own texture ScaleTexture planetex,10,10 EntityTexture plane,planetex Global ship = LoadMesh("fighter5.3ds");replace with your own mesh PositionEntity ship,0,100,0 While Not KeyDown(1) speed# = 1 FlightControls() MoveShip(xrotation,zrotation) MoveCamera() RenderWorld Flip Wend End Function MoveShip(xrotate#,zrotate#) roll#=rollspeed*Sin(zrotate#) pitch#=climbspeed*Sin(xrotate) TurnEntity ship,pitch#,0,roll# MoveEntity ship,0,0,speed# End Function Function MoveCamera() ;I believe there may be a better way to write the following code using TFORMPOINT, but ;this works really well. EntityParent(camera,ship,True) dx#=EntityX(camera) dy#=EntityY(camera) dz#=EntityZ(camera) r#=EntityRoll(camera) p#=EntityPitch(camera) y#=EntityYaw(camera) ;The following 4 lines cause the camera to follow just behind the ship(30 behind, 2 up). ;Pitch roll and yaw are also just behind the ship giving your camera a super smooth action. If r# => 180 Then r# = r# - 360 If r# =< -180 Then r# = r# + 360 TurnEntity camera,-p#,-y#,-r#*(.06) TranslateEntity camera,-dx*.1,(-dy*.1)+2,(-dz)-30 EntityParent(camera,0) End Function Function FlightControls() ;The xrotation and yrotation values are passed to the MoveShip function which ;use the sine wave to give you smooth movement. It is very important these ;values never exceed 90. But 70 is sufficient. If KeyDown(200);x rotation(pitch) If xrotation < 70 Then xrotation = xrotation + climbspeed# If xrotation < 0 Then xrotation = xrotation / 1.1 ;If you use Delta timing then the above line should ;read "xrotation = xrotation / 1.1 ^ FL\SpeedFactor" ;note the (^) not (*) End If End If Else If KeyDown(208) If xrotation > -70 xrotation = xrotation -climbspeed# If xrotation > 0 Then xrotation = xrotation / 1.1 End If End If Else If xrotation <> 0 Then xrotation = xrotation / 1.1 End If End If EndIf If KeyDown(203);z rotation(roll) If zrotation < 70 Then zrotation = zrotation + rollspeed# If zrotation < 0 Then zrotation = zrotation / 1.1 End If End If Else If KeyDown(205) If zrotation > -70 zrotation = zrotation - rollspeed# If zrotation > 0 Then zrotation = zrotation / 1.1 End If End If Else If zrotation <> 0 Then zrotation = zrotation / 1.1 End If End If EndIf End Function
This is Viperfish code, now when you run that, bearing in mind to add your own texture and ship, if you click on left cursor, you will see the ship rolls to the left. What I want to achieve is to make the ship turn left, basically bank left. (Hope that makes some sort of sense?)
I have checked the sample xfighter.bb code which Matty had programmed in Blitz3d, but couldn't see a way of adapting that to this code
Any help would be greatly appreciated :)