Make dynamic object move to parent's location?

Hello all, thank’s for stopping by.

I’m trying to make it so once I parent a dynamic object to another object, the dynamic object also moves to the location of it’s parent.

It’s easy to do if the child object is a static object, but once you set physics to dynamic, it no longer can move relative to i’ts parent.

I included a blend. left blue cube is static, right purple cube is dynamic.
I want the purple cube to act like the blue cube.

cubes_parrent.blend (525.2 KB)

Tips?
Thanks for your time.

spacebar brick on blue, hit the tap button

I want the purple to act like the blue, not the blue act like the purple. :3

Oops, sorry.

Then you need someone who knows bricks better then me, all i can say at this point it that it wont work due to the fact that dynamic objects lose its physics as soon as it get’s parented to an other object.

#edit
does it need to be parented in front, before it reaches the red cube? Or can it be parented after reaching the red cubes position?

As long as it can end up at the exact center of the parent’s origin, and facing the same direction of the parent, that’s ok.

Not a neat way to do this, but does what you want.
What is your goal here, cube walking to an other cube, or is red cube some sort of node to go to?

Because your way will not be a good solution if you add a lot more. you could change the red cube to an empty if it just functions as a node.

anyway with bricks:
edit object(track to)
motion, loc at 0.1, L selected

will move it to the position, but reaching upon the red cube it will keep spinning until it gets out of control, so here is a python version that works. But again i would not use collision/physics settings for the red cube.

python:
cubes_parrent_adjusted.blend (537.6 KB)

I’m gunna test this for a bit and see what I can come up with before replying again. Thanks so far.

I opened your original .blend with Upbge 2.5 and it just works. The cubes blue and purple act identical relative to their respective parents. Except that the purple one gets warped. What am i missing?

Makes me wish I started this project in UPBGE. XD
Good to know though! Thanks.

it’s a brand new project? than i highly recommend Upbge. its another beast :wink:

Heh heh, it’s a very old project.
I 100% should have moved to UPBGE, but… Yeah…

if using bge 2.79 then going to upbge is not bad, only a little bit that you need to adjust, and that little bit is 99.9% scripting, so try it i would say.

@Ranstone hi.
The code you are looking for is something like this -

import bge

def script_name(cont):
    
    cont.owner.localPosition = bge.logic.getCurrentScene().objects["Object_Child"].parent.localPosition

Replace “Object_Child” with the name of the child object that has the parent you want the object that has this script to follow.

He’s not looking for that :woozy_face:
Start reading the OP instead of titles only, then you can give an answer that the TS actually needs.

I looked at this earlier and thought about it. Figured it had something to do with the way dynamics get suspended when parenting and how it must lose it’s steering function…or something. And this seems like it could be a mess with bricks. Not sure why I came back to it later.

Anyway, I didn’t realize Cotaks had uploaded a blend already but I went ahead and put this one up since it has the stipulation of facing the same direction the OP was looking for. Maybe it will help.cubes_parrent_python.blend (99.8 KB)