Hi,
I'm having trouble using the EntityParent command with my Types.
I have 2 types defined :-
Type planet
Field olddist
Field entity
Field scale
End Type
Type bullet
Field entity
Field stage
Field speed
End Type
And I have template sprite for the bullets:-
flare=LoadSprite("bullet.bmp",3)
When I hit the Mouse button, I create a new bullet type:-
If MouseHit(1) And mult=0 Then
ship.bullet=New bullet
ship\entity=CopyEntity(flare)
ship\stage=1
EntityType ship\entity,BULLET_COL
EntityRadius ship\entity,5
PositionEntity ship\entity,EntityX(cam),EntityY(cam),EntityZ(cam)
RotateEntity ship\entity,EntityPitch(cam),EntityYaw(cam),EntityRoll(cam)
ship\speed=acc+30
End If
Pretty Straight forward so far. When the bullet hits a planet though I want to attatch the bullet to the planet so that my "explosion" rotates with the planets rotation.
My collision code looks like this:-
For ship.bullet=Each bullet
If ship\stage=1 Then
MoveEntity ship\entity,0,0,ship\speed
hit=EntityCollided (ship\entity,PLANET_COL)
If hit Then
ship\stage=2
ship\speed=1
EntityParent ship\entity,hit,1
ElseIf EntityDistance(ship\entity,cam)>40000 Then
ship\stage=4
End If
End If
If ship\stage=2 Then
ship\speed=ship\speed+1
ScaleSprite ship\entity,ship\speed,ship\speed
If ship\speed=200 Then ship\stage=3
End If
If ship\stage=3 Then
ship\speed=ship\speed-1
ScaleSprite ship\entity,ship\speed,ship\speed
If ship\speed=0 Then ship\stage=4
End If
If ship\stage=4 Then
FreeEntity ship\entity
Delete ship
End If
Next
Stage 1:- Checks for A Planet Collision or Distance.
Variable "hit" contains the handle of the planet.
EntityParent then assigns hit as the bullet parent.
Stage 2:- Uses the bullet speed field as a sprite scale variable as the bullet is now stationary.
When it gets to the ScaleSprite command I get an "Entity Does Not Exist error!"
When I omit the EntityParent command everything works fine, I just don't get the rotation with the planet.
Can anybody plaese explain why the EntityParent command is removing my sprite entity?
Sorry about my post...How do u add those pretty code boxes?
:-)
Thanks
Phil.
I'm having trouble using the EntityParent command with my Types.
I have 2 types defined :-
Type planet
Field olddist
Field entity
Field scale
End Type
Type bullet
Field entity
Field stage
Field speed
End Type
And I have template sprite for the bullets:-
flare=LoadSprite("bullet.bmp",3)
When I hit the Mouse button, I create a new bullet type:-
If MouseHit(1) And mult=0 Then
ship.bullet=New bullet
ship\entity=CopyEntity(flare)
ship\stage=1
EntityType ship\entity,BULLET_COL
EntityRadius ship\entity,5
PositionEntity ship\entity,EntityX(cam),EntityY(cam),EntityZ(cam)
RotateEntity ship\entity,EntityPitch(cam),EntityYaw(cam),EntityRoll(cam)
ship\speed=acc+30
End If
Pretty Straight forward so far. When the bullet hits a planet though I want to attatch the bullet to the planet so that my "explosion" rotates with the planets rotation.
My collision code looks like this:-
For ship.bullet=Each bullet
If ship\stage=1 Then
MoveEntity ship\entity,0,0,ship\speed
hit=EntityCollided (ship\entity,PLANET_COL)
If hit Then
ship\stage=2
ship\speed=1
EntityParent ship\entity,hit,1
ElseIf EntityDistance(ship\entity,cam)>40000 Then
ship\stage=4
End If
End If
If ship\stage=2 Then
ship\speed=ship\speed+1
ScaleSprite ship\entity,ship\speed,ship\speed
If ship\speed=200 Then ship\stage=3
End If
If ship\stage=3 Then
ship\speed=ship\speed-1
ScaleSprite ship\entity,ship\speed,ship\speed
If ship\speed=0 Then ship\stage=4
End If
If ship\stage=4 Then
FreeEntity ship\entity
Delete ship
End If
Next
Stage 1:- Checks for A Planet Collision or Distance.
Variable "hit" contains the handle of the planet.
EntityParent then assigns hit as the bullet parent.
Stage 2:- Uses the bullet speed field as a sprite scale variable as the bullet is now stationary.
When it gets to the ScaleSprite command I get an "Entity Does Not Exist error!"
When I omit the EntityParent command everything works fine, I just don't get the rotation with the planet.
Can anybody plaese explain why the EntityParent command is removing my sprite entity?
Sorry about my post...How do u add those pretty code boxes?
:-)
Thanks
Phil.