Help With Children
Blitz3D Forums/Blitz3D Beginners Area/Help With Children
| ||
I'm trying to get my shooter to work, and I am having some problems. I need my weapons to shoot right, and when I parent my gun to my pivot, it is not storing the global cooords, it keeps them from when i first started. Even if I set the parent global to true/false. I am using: player model-for collisions pivot- parented to player camera-parented to pivot gun-parented to camera I'm using mouse x/y to determine the gun angle, however I need to know the barrel angle of the gun when it shoots, however it entityroll#, etc won't use the right variables. heres my gun code. And it needs to be edited....... I hacked the castle\demo for a quick level. Graphics3D 800,600,16,2 Global MOVE# Global turn# Global rot# Global fdelay BULLX=CreateSphere() ;LOAD SKYBOX m=CreateMesh() ;front face b=LoadBrush( file$+"_FR.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0 AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3: FreeBrush b ;right face b=LoadBrush( file$+"_LF.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0 AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;back face b=LoadBrush( file$+"_BK.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0 AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;left face b=LoadBrush( file$+"_RT.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0 AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;top face b=LoadBrush( file$+"_UP.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0 AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;bottom face b=LoadBrush( file$+"_DN.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1 AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ScaleMesh m,100,100,100 FlipMesh m EntityFX m,1 HideEntity M ;LOAD CASTLE!!!!!!!!!!!!!!!!!! cast=LoadMesh( "c:\castle\castle1.x" ) ScaleEntity cast,.4,.15,.2 EntityType cast,TYPE_SCENERY player_model=LoadAnimMesh( "c:\castle\mariorun.x" ) ScaleEntity player_model,.2,.2,.2 TranslateEntity player_model,0,-1.25,0 ;HideEntity player_model spark_sprite=LoadSprite( "c:\castle\bigspark.bmp" ) HideEntity spark_sprite bull_sprite=LoadSprite( "c:\castle\bluspark.bmp" ) ScaleSprite bull_sprite,3,3 EntityRadius bull_sprite,1.5 EntityType bull_sprite,TYPE_BULLET HideEntity bull_sprite hole_sprite=LoadSprite( "c:\castle\bullet_hole.bmp",1 ) EntityBlend hole_sprite,2 SpriteViewMode hole_sprite,2 HideEntity hole_sprite ;LOAD ENVIROMENT light=CreateLight() ;"terrain-1.jpg","water-2_mip.bmp","sky","heightmap_256.bmp" TurnEntity light,45,45,0 LAND_TEX=LoadTexture ("C:\CASTLE\TERRAIN-1.JPG") ScaleTexture land_tex,10,10 ;land=LoadTerrain("C:\CASTLE\HEIGHTMAP_256.BMP") ;EntityTexture land,land_tex ;TerrainShading land,True ;PositionEntity land,-1000,-100,-1000 ;ScaleEntity land,2000.0/256,100,2000.0/256 ;EntityType land,TYPE_TERRAIN ;TerrainDetail land,750,True ground=CreatePlane() EntityTexture ground,land_tex PositionEntity ground,0,-100,0 EntityOrder ground,9 OFLOOR=CreatePlane() LAND_TEX2=LAND_TEX EntityTexture OFLOOR,LAND_TEX2 EntityOrder OFLOOR,15 PositionEntity OFLOOR,0,-31,0 water_tex=LoadTexture("C:\CASTLE\WATER-2_MIP.BMP",3 ) ScaleTexture water_tex,20,20 water=CreatePlane() EntityTexture water,water_tex PositionEntity water,0,-30,0 ;END LOAD ENVIROMENT EntityRadius OFLOOR,1 EntityType OFLOOR,2 EntityRadius GROUND,1 EntityRadius PLAYER_MODEL,1.5 EntityType PLAYER_MODEL,1 ;EntityType WATER,2 EntityType GROUND,2 EntityRadius CAST,.025 EntityType CAST,3 ;EntityType LAND,2 ;EntityType BULLET,4 Collisions 1,3,2,3 Collisions 1,2,2,2 Collisions 1,2,2,2 cam=CreateCamera() PositionEntity CAM,0,16,-8 CameraRange CAM,.1,1000 PositionEntity PLAYER_MODEL,0,4,3 light=CreateLight() RotateEntity light,90,0,0 MoveEntity cast,0,-2,0 gun=LoadMesh("c:\gun1.b3d") ;FitMesh gun,0,0,0,.02,.025,.1,1 PositionEntity gun,1,14,-5.4 ScaleEntity GUN,.5,1,1 pivot=CreatePivot() EntityParent PIVOT,PLAYER_MODEL,True EntityParent GUN,PIVOT,True EntityParent cam,pivoT,True MoveMouse 400,300 While Not KeyHit(1) FDELAY=FDELAY-1 GUN_ROT#=0 GUN_PITCH#=0 PositionEntity PIVOT,1,14,-5.4 STRIFE#=0 msg$="" move#=0 turn#=0 shoot=0 If KeyHit(17)=True Or KeyDown(17)=True MOVE#=1 If KeyHit(31)=True Or KeyDown(31)=True MOVE#=-1 If KeyHit(30)=True Or KeyDown(30)=True TURN#=1 If KeyHit(32)=True Or KeyDown(32)=True TURN#=-1 If KeyHit(51)=True Or KeyDown(51)=True STRIFE#=-2 If KeyHit(52)=True Or KeyDown(52)=True STRIFE#=2 curr_my=MouseY() curr_mx=MouseX() If MouseHit(1)=True Or MouseDown(1)=True SHOOT=1 If MouseHit(2)=True Or MouseDown(2)=True SHOOT=2 gun_rot#=0 gun_pitch#=0 Select True ;rem next line exclude Case curr_mx<150 gun_rot#=90 Case curr_mx<200 gun_rot#=75 Case curr_mx<250 gun_rot#=60 Case curr_mx<300 gun_rot#=45 Case curr_mx<350 gun_rot#=30 Case curr_mx>650 gun_rot#=-90 Case curr_mx>600 gun_rot#=-75 Case curr_mx>550 gun_rot#=-60 Case curr_mx>500 gun_rot#=-45 Case curr_mx>450 gun_rot#=-30 End Select ;SET GUN_PITCH Select True Case curr_my<100 gun_pitch#=-50 Case curr_my<125 gun_pitch#=-40 Case curr_my<150 gun_pitch#=-30 Case curr_my<175 gun_pitch#=-20 Case curr_my<225 gun_pitch#=-10 Case curr_my>600 gun_pitch#=50 Case curr_my>500 gun_pitch#=40 Case curr_my>450 gun_pitch#=30 Case curr_my>400 gun_pitch#=20 Case curr_my>350 gun_pitch#=10 End Select If shoot=1 And FDELAY<1 ;msg$="FIRE FIRE FIRE FIRE FIRE FIRE" P.bullet=New bullet P\mesh=CopyEntity(bullx) PositionEntity P\mesh,(EntityX#(PLAYER_MODEL)),( EntityY#(PLAYER_MODEL)),(EntityZ#(PLAYER_MODEL)) TurnEntity P\mesh,GUN_PITCH#,ROT#+GUN_ROT#,0 MoveEntity P\mesh,1.9,16,-3.5 fdelay=20 EndIf ROT#=ROT#+TURN# MoveEntity PLAYER_MODEL,STRIFE#,-.25,MOVE# TurnEntity PLAYER_MODEL,0,TURN#,0 RotateEntity PIVOT,GUN_PITCH#,GUN_ROT#,0 For P.BULLET=Each BULLET MoveEntity P\MESH,0,0,4 Next UpdateWorld RenderWorld roll#=EntityRoll#(GUN) pitch#=EntityPitch#(GUN) yaw#=EntityYaw#(GUN) x#=EntityX#(GUN) y#=EntityY#(GUN) z#=EntityZ#(GUN) Text 10,10,"ROLL: "+ROLL# Text 10,30,"PITCH: "+PITCH# Text 10,50,"YAW: "+YAW# Text 10,70,"X#= "+X# Text 10,90,"Y#= "+Y# Text 10,110,"Z#= "+Z# Text 10,150,"TRISRENDERED="+TrisRendered() Flip Wend End Type BULLET Field MESH Field DURATION End Type |
| ||
Oops, thought you meant this! :D Just kidding. Try adding Global GUN_ROT# Global GUN_PITCH# also, with these commands: roll#=EntityRoll#(GUN) pitch#=EntityPitch#(GUN) yaw#=EntityYaw#(GUN) x#=EntityX#(GUN) y#=EntityY#(GUN) z#=EntityZ#(GUN) Add the GLOBAL parameter like this: roll#=EntityRoll#(GUN,1) I think that should work. Havent reied it, haven't even run your code, because Id have to find/make all the files to load in! |
| ||
You've got a parenting extravaganza going on there which it probably unecessary :-O If you could provide a version of the above that does not require any external media then I'm sure this could be made to be more efficient and less complicated. Up to you I guess. Cheers Stevie |
| ||
thank you very much, doing entityroll#(gun,true) worked. I'll edit the code and post it so you all can see. as soon as I can. laters |