# Python setParent compound not working?

**URL:** <https://blenderartists.org/t/python-setparent-compound-not-working/558459>\
**Category:** Game Engine Support and Discussion\
**Created:** [December 2, 2012, 9:40am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459 "2012-12-02T09:40:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 2, 2012, 9:40am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/1 "2012-12-02T09:40:20Z")

</div>

If I make two cubes manually and the first cube has mouseover triggering for example a simple rotation and the second cube is parented to the first one with compound on, that mouseover works when hovering over both cubes.

However when I try to do the same thing via Python, it doesn’t seem to add the compound at all.  
I tried to parent a freshly adden item in game to a Empty that has a script running with mouse over sensor.  
The script works when I hover over the empty (with box compound on), but it doesn’t work if i hover the other added items.

Is there some tricks or things I should know, when trying to do this thing via Python?  
I checked it with Physics Visualization and it doesn’t show compound to the child object added via Python at all,  
but it shows it on those done manually prehand.

---

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 2, 2012, 9:47am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/2 "2012-12-02T09:47:04Z")

</div>

![](https://blenderartists.org/uploads/default/original/3X/9/c/9c368754ebe67234ce70e4b065cefcd006ed991a.jpg)  

Ok Here’s more information.  
Those both set ups have same physics settings and it seems that for some reason if I use:

```auto
 newLetter.setParent(own, 1, 0) 

```

It will create compounds around each children objects instead of the parent?

---

<div class="post-metadata">

**Author:** ![Rubbernuke](https://blenderartists.org/user_avatar/blenderartists.org/rubbernuke/32/14511_2.png) [@Rubbernuke](https://blenderartists.org/u/Rubbernuke)\
**Post date:** [December 2, 2012, 10:01am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/3 "2012-12-02T10:01:23Z")

</div>

Have you set compound on the parent object in the properties panel? Do you have a test blend?

---

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 2, 2012, 10:39am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/4 "2012-12-02T10:39:13Z")

</div>

[compoundTest.blend](https://blenderartists.org/uploads/default/original/3X/d/a/daef21d813ac94254dbed70eab934e25fc1809ac.blend) (475 KB)

Here’s an example

---

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 2, 2012, 10:44am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/5 "2012-12-02T10:44:58Z")

</div>

btw was suppose to be (own, 1, 1) but still not helping.

---

<div class="post-metadata">

**Author:** ![Rubbernuke](https://blenderartists.org/user_avatar/blenderartists.org/rubbernuke/32/14511_2.png) [@Rubbernuke](https://blenderartists.org/u/Rubbernuke)\
**Post date:** [December 2, 2012, 12:04pm UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/6 "2012-12-02T12:04:35Z")

</div>

Try this:

I changed the compound setting in the properties panel (on the child), and created a spawn object (as in one of my current projects) and it seems to work now (in that mouseover works on children too).

### Attachments

[compoundTest2.blend](https://blenderartists.org/uploads/default/original/3X/b/2/b26466c1c38a458c02a2766d1eff4af583d8d362.blend) (378 KB)

---

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 2, 2012, 6:16pm UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/7 "2012-12-02T18:16:33Z")

</div>

It kind of works but I have following issues:

1. You can’t move the child object afterwards at all because the collision bound doesn’t move along with the child object?
2. If you manipulate the parent object’s scale value during the game, it messes up the compound scale.

EDIT UPDATE: I noticed that this works if you want an simple offset before setting parent:

```auto

newSpawn = scene.addObject("newObject", own, 0)
newSpawn.localPosition[0] = 10
newSpawn.setParent(own, 1, 0)

```

---

<div class="post-metadata">

**Author:** ![Rubbernuke](https://blenderartists.org/user_avatar/blenderartists.org/rubbernuke/32/14511_2.png) [@Rubbernuke](https://blenderartists.org/u/Rubbernuke)\
**Post date:** [December 2, 2012, 11:24pm UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/8 "2012-12-02T23:24:42Z")

</div>

Those issues you mention are limitations of the compound option.

In my case, if I end the child its collision hull is left behind in the compound collision box- I assume something similar is happening to you. Before you ask, there is no reinstance collision mesh that works for compound objects, sadly (unless something new has been added).

Also, children inherit the scale of the emitter (i.e. the parent), so that also sounds ‘normal’ (although unwanted).

If I may ask, what do you want to do with this ingame?

---

<div class="post-metadata">

**Author:** ![Mperonen](https://blenderartists.org/letter_avatar_proxy/v4/letter/m/9de0a6/32.png) [@Mperonen](https://blenderartists.org/u/Mperonen)\
**Post date:** [December 3, 2012, 1:14am UTC](https://blenderartists.org/t/python-setparent-compound-not-working/558459/9 "2012-12-03T01:14:23Z")

</div>

Actually I meant that it really “messes” up the scale, if you check visualization on while changing scaling value of the parent it’ll loose the compound and it’ll only show the parent’s bounds from that point on (at least that was what happened to me) 🙂

I built a script that uses 3d objects to show text on screen, for each letter it spawns a maching object with a letter texture on it.  
i have all the spacings and linings scripted in but then I hit on this issue 🙂  
The system works quite well for my purposes. However I just wished to be able to use the same system to have “dynamic” buttons for menus and such which would use compound for mouse over and such.
