Types and pivots?

Blitz3D Forums/Blitz3D Programming/Types and pivots?

In my game I am making, I want the player (which will always face z, or north) to have a two entities atached to it; p_ship\shield,p_ship\cam.
At first I just had it like this... all entities just travel the same speed...
TranslateEntity p_ship\speeder,p_ship\x_speed#,0,p_ship\z_speed#
TranslateEntity p_ship\shield,p_ship\x_speed#,0,p_ship\z_speed#
	TranslateEntity cam,p_ship\x_speed#*.75,0,p_ship\z_speed#
	TranslateEntity skysphere,-p_ship\x_speed#,0,p_ship\z_speed#

But when I started putting in collisions if the player hits
something it stops but the camera keep going. So I am trying to give the ship a pivot point so all three entities
are attached to it and react the same durring a collision.

Also I am having a problem with hideentity. the origanal entities are not being hidden, not even the player shield.
not a big problem with just one ship one shield I could use the origanal meshes, but all the enemies will also have shields, and when I position my bullets at the player position these entities are blocking the bullets so I can,t fire when the p_shipx is at or around 0 position. Weird.
Heres the game
 Graphics3D 640,480
SetBuffer BackBuffer() 
AutoMidHandle True
;Set up random generator
SeedRnd MilliSecs() 
;load\create meshes___________________________________________________________________________________
;create the backround___________________________________________________________________________________

;set up for colitions for skyphere,player_ship,player_shield,enemyship1

; Set collision type values 
 type_player1=1 ;the player ship
 type_bullet=2 
 type_scenery=3 ;the skysphere
 type_playershield=4
 type_enimy=5



Global skysphere = CreateSphere(16,0)
ScaleEntity skysphere,-1500,-1500,-1500
;EntityRadius skysphere,1500
;EntityBox skysphere,-1500,-1500,-1500,3000,3000,3000
EntityType skysphere,type_scenery


stars= LoadTexture("stars.bmp")
ScaleTexture stars,.135,.135
;EntityTexture skysphere,stars
;EntityFX skysphere,32

grid_tex=CreateTexture( 32,32,8 )
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer( grid_tex )
Color 0,0,64:Rect 0,0,32,32
Color 0,0,255:Rect 0,0,32,32,False
SetBuffer BackBuffer()

plane = CreatePlane()
EntityTexture plane,grid_tex

;The player ship_______________________________________
Global player_ship = LoadAnimMesh("Rat_Hunter.b3d")
EntityShininess player_ship,1
ScaleEntity player_ship,1.75,1.75,1
RotateEntity player_ship ,0,180,0
;player colition_____________________________________________________ 
EntityRadius player_ship,1.75
EntityBox player_ship,-1.75,-1.75,-1.75,2.50,2.50,2.50
EntityType player_ship,type_player1

;______________________________________________________
Global player_shield = CreateSphere()
EntityColor player_shield,30,130,160
EntityAlpha player_shield,.3
EntityShininess player_shield,1
ScaleEntity player_shield,5,3,5
;player colition_____________________________________________________ 
EntityRadius player_shield,1.75
EntityBox player_shield,-1.75,-1.75,-1.75,2.50,2.50,2.50
EntityType player_shield,type_player1


;HideEntity player_shield
Global cam=CreateCamera()
CameraRange cam,1,3000 
PositionEntity cam,0,10,0
light=CreateLight()

;player rocket_________________________________________
baseblue = LoadTexture("baseblue.bmp")
Global rocket1=LoadMesh("rocket.b3d")
EntityColor rocket1,200,0,0
EntityTexture rocket1,baseblue
;RotateEntity rocket1,0,180,0
ScaleEntity rocket1,10,10,10
HideEntity rocket1
;bulet colition______________________________________________________
EntityRadius rocket1,2
EntityBox rocket1,-2,-2,-2,4,4,4
EntityType rocket1,type_bullet

;enemy ship_______________________________________________
Global enemy_ship_1 = LoadMesh("spacefighter.b3d")
RotateEntity enemy_ship_1,0,180,0
ScaleEntity enemy_ship_1,1.5,1.5,1.5
;enimy colition______________________________________________________
EntityRadius enemy_ship_1,.25
EntityBox enemy_ship_1,-1.5,-1.5,-1.5,3,3,3
EntityType enemy_ship_1,type_enimy

HideEntity enemy_ship_1

;PositionEntity player_shield,EntityX(cam),EntityY(cam),EntityZ(cam)
;PositionEntity player_shield,0,2,30

;Global enemy_bullet = CreateSprite()
;Global player_bullet = CreateSprite()

;constants______________________________________________________________________________________________

;Globals________________________________________________________________________________________________
Global player_x
Global player_y
Global player_z   
;types initializations___________________________________________________________________________________
;player type
Type player
 Field x
 Field y
 Field z
 Field x_speed#
 Field z_speed#
 Field speeder
 Field shield ; the players shield ,a sphere
 Field alive
 Field health
 Field shield_health
 Field p_pivot
End Type 

Type enemy
 Field x
 Field y
 Field z
 Field ship
 Field alive
 Field health
 Field shield_health
End Type 

Type bullet
 Field x
 Field y
 Field z
 Field speed
 Field damage
 Field from ;1= player, 2= enemy
 Field mesh
End Type

Type explotion
 Field x
 Field y
 Field from
End Type  

makeplayer(player_shield,player_ship)

;the makeenemy() function will be iterated depending on how high the leval is and create ships depending on leval number
makeenemy();this function will be moved to the initialise leval function not created yet
;set up for collision checking
Collisions type_player1,type_enimy,1,2
;Collisions type_player1,type_player1,1,1
Collisions type_bullet,type_enimy,1,2
Collisions type_bullet,type_scenery,2,1
Collisions type_player1,type_scenery,2,1
;Collisions type_scenery,type_bullet,2,1
;Collisions type_scenery,type_player1,2,1



;Main Game Loopvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
While Not KeyHit(1)
;TurnEntity skysphere,-.03,.02,0 


updateplayer(p_ship.player,player_shield)

If KeyHit(57) p_createbullet()
p_updatebullets()





UpdateWorld()
RenderWorld()
Flip
Wend;end of main game loop^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ClearWorld()
End

;functions______________________________________________________________________________________________--
;create the player____________________________________________________________________________________
Function makeplayer.player(player_shield,player_ship)
 p_ship.player = New player 
 p_ship\p_pivot = CreatePivot()
 p_ship\x = 0
 p_ship\y = 2
 p_ship\z = 25
 p_ship\x_speed# = 0
 p_ship\z_speed# = 0
 p_ship\speeder = CopyEntity(player_ship,p_ship\p_pivot) 
 p_ship\shield = CopyEntity(player_shield,p_ship\p_pivot)
 p_ship\alive = True
 p_ship\health = 100
 p_ship\shield_health = 100
 
 Animate p_ship\speeder ,2,.05,0,0

 For p_ship.player = Each player
    PositionEntity p_ship\p_pivot,p_ship\x,p_ship\y,p_ship\z
	PositionEntity p_ship\speeder,p_ship\x,p_ship\y,p_ship\z
	PositionEntity p_ship\shield,p_ship\x,p_ship\y,p_ship\z
 Next 

 
End Function 
;create the enimies___________________________________________________________________________________
Function makeenemy()
 e_ship.enemy = New enemy
 e_ship\x = 0
 e_ship\y = 2
 e_ship\z = 300
 e_ship\ship = CopyEntity(enemy_ship_1)
 e_ship\alive = True
 e_ship\health = 100
 e_ship\shield_health = 100
 PositionEntity e_ship\ship,e_ship\x,e_ship\y,e_ship\z;temporary
End Function
;update the enimies_____________________________________________________________________________________
;Function EnemyAI()
 ;For e_ship.enemy = Each enemy
 
 

;End Function

;create player bullets________________________________________________________________________________
Function p_createbullet.bullet()
 p_rocket.bullet = New bullet
 p_rocket\x = player_x ;EntityX(p_ship\speeder)
 p_rocket\y = player_y ;EntityY(p_ship\speeder)
 p_rocket\z = player_z ;EntityZ(p_ship\speeder)
 p_rocket\speed = 10
 p_rocket\damage = 30
 p_rocket\from = 1
 p_rocket\mesh = CopyEntity(rocket1);Rocket1 to start out but this will be changeable with a weapos select function
 PositionEntity p_rocket\mesh,player_x,player_y,player_z 
End Function
;update the payer bullets_____________________________________________________________________________
Function p_updatebullets.bullet()
 
 For p_rocket.bullet = Each bullet
	MoveEntity p_rocket\mesh,0,0,p_rocket\speed
 Next

 
End Function


;create enimy bullets___________________________________________________________________________________




;update the backround___________________________________________________________________________________
;update the player____________________________________________________________________________________
Function updateplayer(p_ship.player,player_shield)
 For p_ship.player = Each player
  	
	
 
    
	
	If KeyDown(205) Then
	 	p_ship\x_speed# = p_ship\x_speed#+ .10
		If p_ship\x_speed# >= 1.5 Then p_ship\x_speed# = 1.5
	EndIf 
	If KeyDown(203)  Then
		p_ship\x_speed# = p_ship\x_speed# -.10
		If p_ship\x_speed# <= -1.5 Then p_ship\x_speed# = -1.5
	EndIf 
	If KeyDown(200)  Then 
		p_ship\z_speed#=p_ship\z_speed#+.10
		If p_ship\z_speed# >= 2.5 Then p_ship\z_speed# = 2.5

	EndIf 
	If KeyDown(208)  Then 
		p_ship\z_speed#=p_ship\z_speed#-.10
		If p_ship\z_speed# <= -1.5 Then p_ship\z_speed# = -1.5
	EndIf 

	;TranslateEntity p_ship\speeder,p_ship\x_speed#,0,p_ship\z_speed#
	;TranslateEntity p_ship\shield,p_ship\x_speed#,0,p_ship\z_speed#
	TranslateEntity cam,p_ship\x_speed#*.75,0,p_ship\z_speed#
	;TranslateEntity skysphere,-p_ship\x_speed#,0,p_ship\z_speed#
	TranslateEntity p_ship\p_pivot,p_ship\x_speed#,0,p_ship\z_speed#


	;PointEntity cam,p_ship\speeder
    ;get player locations for bullets
	;player_x = EntityX(p_ship\speeder)
	;player_y = EntityY(p_ship\speeder)
	;player_z = EntityZ(p_ship\speeder)

    player_x = EntityX(p_ship\p_pivot)
	player_y = EntityY(p_ship\p_pivot)
	player_z = EntityZ(p_ship\p_pivot)



 Next 

End Function 

;enimy AI ______________________________________________________________________________________________ 
;update the enimy bullets_________________________________________________________________________________


It would be easier to make the player the parent of the camera (i.e. EntityParent cam,player). As for the meshes not being hidden, I notice you have remmed out your hiding of the shield. However another thing to do is to move the original meshes to some silly place like PositionEntity ent,0,-10000,0. That should help :)