Im working on a game that needs the ability to build cars and rockets out of cubes, with thrusters and what not, i was thinking for like a rocket to have a thruster as the core, then i place blocks around/on it that when are right clicked will “weld” or stick to the thruster, but the only way i could think of doing this is parenting, but the problem is i can have it parent to the thruster but how do i get it to dynamically parent to other objects that i want it to, say other thrusters that are spawned in?
How are you parenting things now, and how good at Python are you?
just using the parent actuator, and i dont know python
Then your task might be a bit more difficult:
Parenting means that the children inherit the motion of the parent- so any additional thrusters would be no good as they automatically use the ‘core’ thruster for movement reference. Also, with the parent logic brick you can only parent to one defined object- not so good in a dynamic situation.
Another question is do you have a menu system to allow you to ‘design’ your cube rockets / cars? If not, how are you organising things (i.e. how do you get your spawned objects organised before you parent them)? If you have a blend handy that would be useful to see your setup.
I just have each object on a second layer and it gets spawned in depending on the current property number of the adder.
OK, I’m pretty sure there is no way to do what you want in logic alone.
As a start, I have made a simple demo using Python. It is not polished at all, so be warned!
It works like this: left click an object. This object becomes the parent. Right click another object, This becomes the child. Press SPACE and they are joined together. You can keep adding other objects as you see fit by repeating the same process. There is a cube that acts as a co-ordinator too (and is set to invisible).
Be aware the process is a bit simple- there are many features and safeguards I have not made! To find out what objects you have clicked look in the output window (names are printed).
To prove things are parented, each shape in the demo has a control (refer to the logic bricks). Children can move on their own, but only the parent moves them all.
Like I said, its a start (and I’m a beginner at Python, so forgive my slow replies). If you have any questions just ask, and I will try to answer them.
select and parent.blend (483 KB)
this works really well, ill continue to use it and if i come across anything ill let you know, thanks