ok thank you, the reason i ask is because i started messing around with my fps engine that i started workin on a long time ago and i am having problem with my camera running up the walls while i hold the jump button. i know why it does this(i'm checking collision with my whole level) but i dont know how to fix it. here is my code. i was thinking if i can't get anything else to work that i would put an invisible flat mesh that is not wider then the collision radius at the bottom of the player(pivot)
; * FPS sample.
; * Program code by Simon Harrison (si@...).
; * Gargoyle model by Adam Gore.
; Graphics values
Const width=640,height=480,depth=16
; Collision type values
Const type_camera=1
Const type_scenery=3,type_ladders=4 ; Destination
; Camera position, angle values
Global cam_x#,cam_z#,cam_pitch#,cam_yaw# ; Current
Global dest_cam_x#,dest_cam_z#,dest_cam_pitch#,dest_cam_yaw# ; Destination
Global jumped = 0
Global PGrav# = 0.0
Global Grav# = 0.2
; Set display mode
Graphics3D width,height,depth
SetBuffer BackBuffer()
; Set up camera
Global camera=CreateCamera()
CameraRange camera,1,600
EntityRadius camera,7.5
EntityType camera,type_camera
PositionEntity camera,10,10,10
; Set up lights
AmbientLight 191,191,191
Global light=CreateLight()
LightColor light,31,31,31
RotateEntity light,45,0,0
; Load level
Global level=LoadMesh("interior.x")
ScaleEntity level,100,100,100
EntityType level,type_scenery
EntityPickMode level,2
; Load ladders collision mesh
Global ladders=LoadMesh("ladders.x")
ScaleEntity ladders,100,100,100
EntityType ladders,type_ladders
EntityAlpha ladders,0
; Initialise collisions
Collisions type_camera,type_scenery,2,3
Collisions type_camera,type_ladders,2,2
; Main loop
; ---------
Global old_time=MilliSecs()
While Not KeyHit(1)
PGrav# = PGrav# - Grav#
TranslateEntity camera,0,PGrav#,0
If EntityCollided(camera,type_scenery)
PGrav = 0.0
jumped = 0
EndIf
UpdateGame()
UpdateWorld
RenderWorld
; FPS
frames=frames+1
If MilliSecs()-render_time=>1000 Then fps=frames : frames=0 : render_time=MilliSecs()
Text 0,0,fps
Flip
Wend
End
; --------------------
; Update game function
; --------------------
Function UpdateGame()
GameInput()
End Function
; -------------------
; Game input function
; -------------------
Function GameInput()
; Mouse look
; ----------
; Mouse x and y speed
mxs=MouseXSpeed()
mys=MouseYSpeed()
; Destination camera angle x and y values
dest_cam_yaw#=dest_cam_yaw#-mxs
dest_cam_pitch#=dest_cam_pitch#+mys
; Current camera angle x and y values
cam_yaw=cam_yaw+((dest_cam_yaw-cam_yaw)/5)
cam_pitch=cam_pitch+((dest_cam_pitch-cam_pitch)/5)
RotateEntity camera,cam_pitch#,cam_yaw#,0
; Rest mouse position to centre of screen
MoveMouse width/2,height/2
; Camera move
; -----------
; Forward/backwards - destination camera move z values
If KeyDown(17)=True Or MouseDown(2)=True Then dest_cam_z=1
If KeyDown(31)=True Then dest_cam_z#=-1
; Strafe - destination camera move x values
If KeyDown(32)=True Then dest_cam_x=1
If KeyDown(30)=True Then dest_cam_x=-1
If KeyDown(57) And jumped = 0
PGrav# = 3.0
jumped = 1
FlushKeys
EndIf
; Current camera move x and z values
cam_z=cam_z+((dest_cam_z-cam_z)/5)
cam_x=cam_x+((dest_cam_x-cam_x)/5)
; Move camera
MoveEntity camera,cam_x,0,cam_z
dest_cam_x=0 : dest_cam_z=0
; Climb ladders
If EntityCollided(camera,type_ladders)<>0 Then PGrav# = PGrav# + .25
End Function
note: most of this code isn't mine it is the fps demo that comes with blitz but my engine isn't this code i was just testing my stuff in an actual level(instead of terrain) so i used that
|