In game engine with python, add appendage to object I'm doing scripting in the game engine.  I have two basic objects, a "SeaFloor" and "Kelp".  I have python classes for each and the game engine.

My goal is to add the Kelp object to the scene and root it to the SeaFloor, so in the physics of the game it won't be moved by fish or current.  Also, as the kelp grows, I only want it to grow "up".

I can get the kelp to appear using:

kelp = self.scene.addObject("Kelp", "SeaFloor")
kelp.worldPosition = pos


I think I have to do this with constraints, but I don't understand them very well.  I would appreciate some advice on how to lock those two together.
These are two different tasks. Lets deal with them separately.

Grow

I suggest you let the objects grow via an animation (e.g. shape-key, armature). With that you have full control how it grows.

When you use scaling ensure the object origin is at the button of the plant as scaling is always relative to the origin.

Positioning

A simple solution is to check the ground "under" the object. Typically "under" is along -Z.

Perform a ray check along -Z starting from current position. Check for ground (property filter). Then you can place the object at the found hitPosition.

Check the BGE API for rayCast()

Example:

lookAtPosition = kelp.worldPosition.copy()
lookAtPosition .z -= 1 # position below current position
distanceToCheck = 100.0

hitObject, hitPosition, hitNormal = rayCast(
    lookAtPosition,
    kelp.worldPosition,
    distanceToCheck,
    "ground")

kelp.worldPosition = hitPosition


I hope it helps