I would like to ask for some help.
I would like to achieve that,if I’m rotating an object,an other object follow the rotation of the rotated object.
In other game development tools,languages this technique what I’m looking for is called “Parenting”, which makes an object a parent of an other object which became a “child” object this way.The aim of this feature is that,the child object always keep it position relating to it parent object.
So,if I positioning the child object on the left side of the parent object,even if the parent object is rotating,the child object is follow it rotation and stay on the left side of the parent object.Also valid for the child object’s direction and distance relating to parent object.
The child always keep it position,direction and distance relating to parent.
This feature also called some places “Pinning”,so we can “pin” an object to an other. Same thing only called different.
In GameDevelop I can’t find this feature and I get stuck
I have no idea how to make it,because in the past whatever tool I’ve been used it had this feature.
Anybody could help me please,how to achieve this in GameDevelop?
It is easy if you know ‘who are the objects’, you only need one event and two actions: first action copy to the child object the position of the parent object, and second action copy the direction.
Game Develop has two basic sprite points: ‘Origin’ and ‘Centre’, ‘Origin’ is the real object’s position, and ‘Centre’ is over the sprite is rotated.
In your parent object, you put the ‘Origin’ and ‘Centre’ points where you like. But you have to add a point (i.e. ‘Child1’) and put it where the child object must be.
In your child object, you don’t add any point, but you have to put the ‘Origin’ and ‘Centre’ points in the same place, because if the ‘Centre’ is not in the same position of ‘Origin’ the rotation will be degenerated, not the same of the parent object, here is an image to explain:
Where:
Blue point is the ‘Origin’
Red point is the ‘Centre’
Green point is the ‘Child1’
Note that in the child, pink object, the ‘Origin’ and ‘Centre’ are in the same place.
Now you add this event:
Always:
........Do = Parent.PointX(Child1) and = Parent.PointY(Child1) to the position of the object Child
........Do = Parent.Direction() to the direction of Child
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):
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.
I’ve just made an example of how to properly implement a child/parent engine with Game Develop Check it here: viewtopic.php?f=22&t=4369
Of course, it can be extended to share more information between the child and the parent: It’s up to the game designer to do such modification so that the system fulfill his need