From Shoot Em Up Kit
Parent and Child Items
In-game items can be attached to one another. A tank could have a turret attached; or the Player ship could have a spotlight attached. The item that has the other attached to it is known as the Parent item. The Item which is attached is referred to as the Child item. The child item uses the parent’s position and rotation properties as the basis for its own position and rotation. A turret on a tank could still rotate independently, but if the base of the tank (the parent) rotated then it would still affect the direction the turret was facing.
The child item is usually attached using a Tag point on the parent. This will specify the location and rotation of the child. The Shoot ‘Em Up Kit provides options to set the relationship between the parent and child items.
The child item can set which item is its parent. This can be done by selecting the item in the Level Editor and setting the Parent properties so it is already set-up when the level starts; or you can choose to Assign Parent In-Game and attach the child to the parent using an Action event.
If the Parent item has any Tags set-up then a Tag can be selected for the child to attach to. The tag will specify the position and rotation (assuming Use Position and Use Rotation properties are set).
Use Position - This specifies whether the child item will use the parent’s position or, if a Tag has been specified, the Parent’s Tag Position.
Use Rotation - This specifies whether the child item will use the parent’s position or, if a Tag has been specified, the Parent’s Tag Position.
Use Offset - This specifies whether the child item will use an offset from the parent’s position or Tag Position. If an offset is required then the X, Y and Z co-ordinates of the offset values can be set.
The Use Health property allows you to choose whether the child item shares its parent’s health. This would usually be true for a tank’s turret as the base and turret can be considered both parts of the same tank. When the base is destroyed the turret is too.
Only Active with Parent
Some items should only become active once they’re attached to a parent. A weapon pick-up, for example, should only become active and allowed to fire once it has been collected and attached to the player ship. If the item is dropped it will become inactive again.
There are actions for attaching and detaching child items.
A child item can be attached to a parent by using the Attach child action on an event in the parent’s Action tab. For example, to allow a player to pick-up a weapon you would use the Collision event on the Player’s Action tab. When the player collided with the weapon pick-up the Collision event would be activated and the item the player collided with would be attached as a child.
A child item can be detached from its parent using the Detach Child option. For example, an attached weapon could be dropped by responding to a button press event on the Player’s Action tab. If the Action is set to Detach Child, then any attachments would be detached.
The Attach/Replace Child option is a combination of Attach Child and Detach Child. If the Parent doesn’t have any child items attached, then it will attach the item referenced by the event (e.g. the item the Player has collided with if it’s a collision event). If the Parent already has a child item then the Parent’s current child item will be detached and the new item will be attached instead.