How to make an object parent to another?

I’m sure simply adding a variable to describe if the object is child or parents would do this just fine. Each object could have Variable family = ‘child’ or Variable family = ‘parent’ and then when an object where family = ‘parent’ moves, then all objects ‘child’ copy it. If you wanted to set this up for mass amounts of objects, you can simply the link objects and do this (in this example, just to match the movespeed, but any action could be copied):

[code]
Create object Ship
Ship.Variable(family) = ‘parent’

Create object SupportShip
Supportship.Variable(family) = ‘child’
Link SupportShip and Ship

If(Ship.Variable(movespeed) > 0)
take into account all SupportShip linked to Ship
SupportShip.Variable(family) = child |||| Actions: Do = Ship.Variable(movespeed) to variable movespeed of SupportShip.[/code]

I’m currently writing an RTS type game in GD and in the next few days will be embarking on the creation of some parent/child type code for one of the units (a leader). I’ll put it up here when I’m done with it. :wink:

1 Like