In my 3d game the camera is the player. I want it to have all the capabilities of a normal human being.At the moment it can float up to the ceiling of my level, but this is not natural. How can I prevent this? I want it to be able to climb steps but only to be able to jump a foot or so. Thanks.
human capabilities
Blitz3D Forums/Blitz3D Beginners Area/human capabilities In the 3D samples directory of your main Blitz3D directory do you have a folder called 'zenith' which leads to 'scare.bb'?
You may or may not have this - this is one of the original demos shipped with B3D, but it may not be included in your version.
You may or may not have this - this is one of the original demos shipped with B3D, but it may not be included in your version.
Oh god, I remember writing that in 2001 >_>
You can also check out example code in the Code Archives: http://www.blitzmax.com/codearcs/codearcs.php
Basically need to apply gravity to the camera by continuously moving it down the Y axis a small amount. Once you learn how to do that you can expand on it by stopping the gravity force when the player is touching the ground.
Basically need to apply gravity to the camera by continuously moving it down the Y axis a small amount. Once you learn how to do that you can expand on it by stopping the gravity force when the player is touching the ground.
Hi, I'm pretty new to Blitz3D... but I've made a FP camera "player"... and it climbs steps and "jumps"... dunno if this code is any use to you?
; Simple FP walker by Quantum
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
;----loading screen And background music (Delete If Not required... remove `;` if required)
;music=LoadSound("theme.mp3") ; ENTER LINK TO REQUIRED AUDIO TRACK
;If music
; LoopSound music
; mc=PlaySound(music)
;EndIf
;loading screen image
;logo=LoadImage("loadpic.jpg") ; ENTER LINK TO REQUIRED LOADING IMAGE
;MidHandle logo
;Cls
;DrawBlock logo,GraphicsWidth()/2,GraphicsHeight()/2
;Flip
;Delay 6000
;-------------------------------------------------------------------
frameTimer=CreateTimer(30) ; FRAME RATE LIMITER PART1 of 2
Collisions 1,2,2,2
player=CreatePivot()
PositionEntity player,45,-8,-800 ;PositionEntity view,45,55,-250
EntityRadius player,50,50 ; set player sphere radius to enable step climbing
EntityType player,1
camera=CreateCamera(player)
CameraRange camera,10,15000 ; clipping & view distance
CameraClsColor camera,255,0,0
PositionEntity camera,0,1,0
TranslateEntity camera,0,60,0 ; eyes height
AmbientLight 100,100,100
mesh=LoadMesh("temple1.b3d") ; ENTER LINK TO SCENERY MODEL
UpdateNormals mesh
sky=LoadMesh("BigCumulus_day_SPHERE.x") ; ENTER LINK TO SKYBOX (DELETE IF NOT REQUIRED)
RotateEntity sky,0,0,0
ScaleEntity sky,495,495,495
PositionEntity sky,0,0,150
tree=LoadMesh("tree1.b3d") ; VARIOUS SCENERY OBJECTS (DELETE IF NOT REQUIRED)
RotateEntity tree,0,0,0
ScaleEntity tree,4,4,4
PositionEntity tree,422,-130,-541
EntityType tree,2 ; make tree collidable
tree2=LoadMesh("tree1.b3d") ; VARIOUS SCENERY OBJECTS (DELETE IF NOT REQUIRED)
RotateEntity tree2,0,0,0
ScaleEntity tree2,4,4,4
PositionEntity tree2,-400,-130,-541
EntityType tree2,2 ; make tree collidable
;------end block
EntityFX mesh,1
EntityType mesh,2
sp#=1.25......... PLAYER MOVEMENT SPEED
ey#=EntityY(player)
; ----------------------------------------MAINLOOP----------------------------------------
While Not KeyHit(1)
If KeyHit(17) ; W key for wire frame view
wire=1-wire
WireFrame wire
EndIf
yv#=EntityY(player)-ey
ey=EntityY(player)
If KeyHit(57) Then yv=10 ; Jump gravity... SPACE TO JUMP
MoveEntity player,0,yv-1.5,0 ; gravity... Adjust to make stair climbing more realistic
p_angle#=(p_angle#-mxs#) ; angle...
If p_angle#>360 Then
p_angle#=p_angle#-360
p_smooth_angle#=p_smooth_angle#-360
EndIf
If p_angle#<0 Then
p_angle#=p_angle#+360
p_smooth_angle#=p_smooth_angle#+360
EndIf
c_angle#=(c_angle#+mys#)
If c_angle#>360 Then
c_angle#=c_angle#-360
c_smooth_angle#=c_smooth_angle#-360
EndIf
If c_angle#<0 Then
c_angle#=c_angle#+360
c_smooth_angle#=c_smooth_angle#+360
EndIf
p_smooth_angle#=p_smooth_angle#-((p_smooth_angle#-p_angle#)/2.5)
c_smooth_angle#=c_smooth_angle#-((c_smooth_angle#-c_angle#)/2.5)
RotateEntity player,0,p_smooth_angle#,0
RotateEntity camera,c_smooth_angle#,0,0
If KeyDown(200) Then MoveEntity player,0,0,sp
If KeyDown(208) Then MoveEntity player,0,0,-sp
If MouseDown(2) Then MoveEntity player,0,0,sp ; right mouse button pressed - MOVE FORWARD
If MouseDown(1) Then MoveEntity player,0,0,-sp ; left mouse button pressed - MOVE BACKWARD
UpdateWorld
RenderWorld
Text 0,48,"Press `Esc` to Quit... `SPACE` to jump"
Text 0,16,"Triangles Rendered:"+TrisRendered()
Text 0,32,"Camera Position: "+EntityX(camera,1)+" "+EntityY(camera,1)+" "+EntityZ(camera,1)
mxs#=MouseXSpeed()/4.0
mys#=MouseYSpeed()/4.0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
Flip
WaitTimer(frameTimer) ; FRAME RATE LIMITER PART2 of 2
Wend
End
; Simple FP walker by Quantum
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
;----loading screen And background music (Delete If Not required... remove `;` if required)
;music=LoadSound("theme.mp3") ; ENTER LINK TO REQUIRED AUDIO TRACK
;If music
; LoopSound music
; mc=PlaySound(music)
;EndIf
;loading screen image
;logo=LoadImage("loadpic.jpg") ; ENTER LINK TO REQUIRED LOADING IMAGE
;MidHandle logo
;Cls
;DrawBlock logo,GraphicsWidth()/2,GraphicsHeight()/2
;Flip
;Delay 6000
;-------------------------------------------------------------------
frameTimer=CreateTimer(30) ; FRAME RATE LIMITER PART1 of 2
Collisions 1,2,2,2
player=CreatePivot()
PositionEntity player,45,-8,-800 ;PositionEntity view,45,55,-250
EntityRadius player,50,50 ; set player sphere radius to enable step climbing
EntityType player,1
camera=CreateCamera(player)
CameraRange camera,10,15000 ; clipping & view distance
CameraClsColor camera,255,0,0
PositionEntity camera,0,1,0
TranslateEntity camera,0,60,0 ; eyes height
AmbientLight 100,100,100
mesh=LoadMesh("temple1.b3d") ; ENTER LINK TO SCENERY MODEL
UpdateNormals mesh
sky=LoadMesh("BigCumulus_day_SPHERE.x") ; ENTER LINK TO SKYBOX (DELETE IF NOT REQUIRED)
RotateEntity sky,0,0,0
ScaleEntity sky,495,495,495
PositionEntity sky,0,0,150
tree=LoadMesh("tree1.b3d") ; VARIOUS SCENERY OBJECTS (DELETE IF NOT REQUIRED)
RotateEntity tree,0,0,0
ScaleEntity tree,4,4,4
PositionEntity tree,422,-130,-541
EntityType tree,2 ; make tree collidable
tree2=LoadMesh("tree1.b3d") ; VARIOUS SCENERY OBJECTS (DELETE IF NOT REQUIRED)
RotateEntity tree2,0,0,0
ScaleEntity tree2,4,4,4
PositionEntity tree2,-400,-130,-541
EntityType tree2,2 ; make tree collidable
;------end block
EntityFX mesh,1
EntityType mesh,2
sp#=1.25......... PLAYER MOVEMENT SPEED
ey#=EntityY(player)
; ----------------------------------------MAINLOOP----------------------------------------
While Not KeyHit(1)
If KeyHit(17) ; W key for wire frame view
wire=1-wire
WireFrame wire
EndIf
yv#=EntityY(player)-ey
ey=EntityY(player)
If KeyHit(57) Then yv=10 ; Jump gravity... SPACE TO JUMP
MoveEntity player,0,yv-1.5,0 ; gravity... Adjust to make stair climbing more realistic
p_angle#=(p_angle#-mxs#) ; angle...
If p_angle#>360 Then
p_angle#=p_angle#-360
p_smooth_angle#=p_smooth_angle#-360
EndIf
If p_angle#<0 Then
p_angle#=p_angle#+360
p_smooth_angle#=p_smooth_angle#+360
EndIf
c_angle#=(c_angle#+mys#)
If c_angle#>360 Then
c_angle#=c_angle#-360
c_smooth_angle#=c_smooth_angle#-360
EndIf
If c_angle#<0 Then
c_angle#=c_angle#+360
c_smooth_angle#=c_smooth_angle#+360
EndIf
p_smooth_angle#=p_smooth_angle#-((p_smooth_angle#-p_angle#)/2.5)
c_smooth_angle#=c_smooth_angle#-((c_smooth_angle#-c_angle#)/2.5)
RotateEntity player,0,p_smooth_angle#,0
RotateEntity camera,c_smooth_angle#,0,0
If KeyDown(200) Then MoveEntity player,0,0,sp
If KeyDown(208) Then MoveEntity player,0,0,-sp
If MouseDown(2) Then MoveEntity player,0,0,sp ; right mouse button pressed - MOVE FORWARD
If MouseDown(1) Then MoveEntity player,0,0,-sp ; left mouse button pressed - MOVE BACKWARD
UpdateWorld
RenderWorld
Text 0,48,"Press `Esc` to Quit... `SPACE` to jump"
Text 0,16,"Triangles Rendered:"+TrisRendered()
Text 0,32,"Camera Position: "+EntityX(camera,1)+" "+EntityY(camera,1)+" "+EntityZ(camera,1)
mxs#=MouseXSpeed()/4.0
mys#=MouseYSpeed()/4.0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
Flip
WaitTimer(frameTimer) ; FRAME RATE LIMITER PART2 of 2
Wend
End