Local Position not work

I’m having a strange problem, which I never had. The commands localPosition and worldPosition work in similar ways, but one uses the world position and the other the local position, but localPosition not use the local position, all two use the world position. Can somebody help me?

localPosition is only relevant when the object is a “child” of another.

Yeah, I know. I put four objects as children of another object,
I create a list that takes all these relatives and tries to apply a local position on them, since they are in different directions, it was for them to go in different directions.

i want use the local position of object for move him.

here’s my code:

def __battery__(self):
        if len(self.object.children) != 0:
            try:
                self.object['radian'] = 0.0
                battery =  [obj for obj in self.object.children if obj.name.startswith("Weapon_battery")]
                def corrector__():
                    for bat in battery:
                        pos_ch = ((sin(self.object['time']*self.object['Velocity'])/20)-0.4)
                        pos = bat.localPosition
                        pos_copy = bat.localPosition.copy()
                        pos[2] = pos_ch
                    
                        def __ori__():
                            self.object['radian'] = ((self.object['radian']*0.99)+(uniform(-180, 180)*0.01))
                        __ori__()
                corrector__()
            except:
                pass 

object.applyMovement([x, y, z], True)
1 Like

might need to got the object properties, and reselect “object” as parent type to reset the coords

1 Like

a workaround is to parent the battery to an empty, now animate the battery. Now you can place the battery where you want and rotate the empty to fit the position, it should work how it should now.

1 Like

Okay, this thread clears a bit of my understanding here as well - I was wondering about this also when I had several parent/child relations like objectA is parent to objectB is parent to objectC.

What I learn here is, that “localPositon” is NOT the “local” orientation which we know from the viewport, It’s more the “parentSpace” actually. If so, this applies to all of the locall attributes of the GameObject class, right?

1 Like

Yes I understood. But I already solved the problem by applying movement, and not changing the location.

Thank’s for the help guys!

If your applying movement you are changing your location, whether it’s world or local positioning :slight_smile: