Sign in to follow this  

Help with blitz3d adding animations

Recommended Posts

Newbie31    100
Hi, I am a newb working with programming and need some help with blitz3d, I am trying to get 2 animations working for a modle. What I want is to have and idle animation and an animation that plays when ENTER is pressed. Both animations work when used alone but only the first works when used together. Can anyone help. Her is the code and models I'm using : Heres what I got. ;Set Graphics And Global Constraints ;Set Graphics buffer Graphics3D 800,600,2,2 SetBuffer BackBuffer() ;Set collision type values PLYER=1 SCENE=2 ;Global Constraints Global h_value=50 ;------------------------------------------------------------------------------------ ;Create Cameras ;Create Camera 1 camera1=CreateCamera() PositionEntity camera1,20,5,0 RotateEntity camera1,0,90,0 ;Create Camera 2 camera2=CreateCamera() PositionEntity camera2,0,5,-10 ;Create Active Camera act_cam=CreateCamera() PositionEntity act_cam,20,5,0 RotateEntity act_cam,0,90,0 CameraRange act_cam,.1,100 ;------------------------------------------------------------------------------------ ;Create pivot piv01=CreatePivot() PositionEntity piv01,0,0,0 ;------------------------------------------------------------------------------------ ;Create Lights ;Create Light Light=CreateLight() RotateEntity light,0,0,0 ;------------------------------------------------------------------------------------ ;Create Objects ;Create Plane plane=CreatePlane() EntityRadius plane,1 EntityType plane,SCENE PositionEntity plane,0,0,0 ;Create Cube cube1=CreateCube() EntityRadius cube1,1 EntityType cube1,SCENE PositionEntity cube1,0,1,5 ;Create Cube cube2=CreateCube() EntityRadius cube2,1 EntityType cube2,SCENE PositionEntity cube2,0,10,5 ;------------------------------------------------------------------------------------ ;Load Meshes ;Load Player Mesh player=LoadAnimMesh("rat_idle.b3d") LoadAnimSeq player,("rat_ani.b3d") EntityRadius player,1 EntityType player,PLYER PositionEntity player,0,0,0 ScaleEntity player,0.1,0.1,.1 RotateEntity player,0,90,0 ;------------------------------------------------------------------------------------ ;Load Textures ;1 TERRAIN terr=LoadTexture("GRASS2.jpg") ;2 CRATE crate=LoadTexture("wcrate.jpg") ;------------------------------------------------------------------------------------ ;Apply Textures To Entities EntityTexture plane,terr EntityTexture cube1,crate EntityTexture cube2,crate ;------------------------------------------------------------------------------------ ;Set collision method and response values method=2 response=2 ;------------------------------------------------------------------------------------ ;Set animations ;Set Player Animation Animate (FindChild(player,"Rat")),1,0.5,0,0 ;------------------------------------------------------------------------------------ ;Set Key Functions While Not KeyDown( 1 ) ;Animation controls If KeyDown( 28 ) If AnimSeq(player)=0 Animate player,1,1,0,0 Else If AnimSeq(player)=1 Animate player,2,1,1,0 EndIf ;Case Select Camera --------[Might be better with {CameraProjMode camera,mode}] If KeyHit( 46 ) whichcamera% = 1-whichcamera% FreeEntity act_cam Select whichcamera% Case 0 ;Create Camera 1 camera1=CreateCamera() PositionEntity camera1,20,5,0 RotateEntity camera1,0,90,0 ;CameraFogRange camera1,1,100 CameraRange camera1,.1,100 Case 1 ;Create Camera 2 camera2=CreateCamera() PositionEntity camera2,0,5,-10 CameraFogRange camera1,1,100 CameraRange camera2,.1,100 End Select End If ;Set Health Variable h_value=h_value If CountCollisions(player) And h_value <100 And h_value >0 ;If KeyHit( 3 ) Then h_value=h_value+10 h_value=h_value-2 MoveEntity player,-1,0,0 EndIf ;Set Magick Variable m_value=m_value If CountCollisions(player) And m_value <100 And m_value >0 ;If KeyHit( 4 ) Then m_value=m_value+10 m_value=m_value-2 MoveEntity player,-1,0,0 EndIf ;Move camera If KeyDown( 205 )=True Then TurnEntity camera1,0,-1,0 If KeyDown( 203 )=True Then TurnEntity camera1,0,1,0 If KeyDown( 200 )=True Then MoveEntity camera1,0,0,0.1 If KeyDown( 208 )=True Then MoveEntity camera1,0,0,-0.1 If KeyDown( 205 )=True Then TurnEntity camera2,0,-1,0 If KeyDown( 203 )=True Then TurnEntity camera2,0,1,0 If KeyDown( 200 )=True Then MoveEntity camera2,0,0,0.1 If KeyDown( 208 )=True Then MoveEntity camera2,0,0,-0.1 ;Move Player If KeyDown( 30 )=True Then TurnEntity player,0,1,0 If KeyDown( 32 )=True Then TurnEntity player,0,-1,0 If KeyDown( 17 )=True Then MoveEntity player,0,0,0.05 If KeyDown( 31 )=True Then MoveEntity player,0,0,-0.05 If KeyDown( 16 )=True Then MoveEntity player,0,0.1,0 If KeyDown( 18 )=True Then MoveEntity player,0,-0.1,0 ;------------------------------------------------------------------------------------ ;Enable Collions between type_character and type_scenery Collisions PLYER,SCENE,method,response ;------------------------------------------------------------------------------------ UpdateWorld RenderWorld ;------------------------------------------------------------------------------------ ;Set Onscreen Display Text 0,0,"Use cursor keys to move about the infinite plane" Text 0,20,"Press [C] to toggle between Cameras" ;Create HUD Text 50,450,h_value Color 0,255,0 Text 50,500,"Health" Color 255,0,0 Rect 50,520,100,10,1 Color 0,255,0 Rect 50,520,h_value,10,1 Color 0,255,0 Text 50,470,m_value Color 0,255,0 Text 50,540,"Magick" Color 255,0,0 Rect 50,560,100,10,1 Color 0,255,0 Rect 50,560,m_value,10,1 Flip Wend End

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this