How can I get this spider to stick to an animated mesh as it deforms?

Once again, in case you missed the last several times I said this, simple spheres and blocks moving at 1 kilometer per decade are not the issue. The issue is complex deformations of complicated objects deforming quickly, something you never addressed. Dropped rays alone don’t account for this. They will hit the mesh, but if the mesh deforms from underneath the spider quickly, the spider won’t be able to fall quickly enough to the deformed surface and will instead fall to infinity along its last calculated ray. It’s all physics, this kind of thing can be achieved in real life easily with something like magnets, glue or velcro, so there is likely a way to do it in blender.

I move the object relative to the object under them

no matter how it moves because the movement is local to the last position

object.worldPosition = oldObj.worldTransform*oldLocal

convert point relative to object


local = object.worldOrientation.inverted( point - object.worldPosition) 

to convert back to world space next frame

point = object.worldTransform*stored_local

You’re still working with object origins which is how their location is defined. I’m not talking about the origin of the object, I’m talking about each individual vertex as it deforms that comprises the object itself. The currently proposed script projects a ray that hits the surface of a mesh as it deforms, that’s a good start. The problem, which I will state yet again, is that the simple ray method does not move the spider along with the nearest vertex or face or along the deformation of each bone. The spider does not “twist” with the surface of a mesh as a bone deforms it, it only projects downward like a floor. You might suggest some kind of child-of constraint, but then the problem with that is a child-of constraint is then that it’s only of one bone, so if the bone rotates 20 units away before the spider has even reached it, then the spider will still translate or rotate with it.

emptes parent to the bones -> shape objects are moved each frame to match the bones.

bones twist -> empties twist -> spider twists.

object.worldTransform = empty.worldTransorm

I don’t think you can go any further than this without using local to empties compared to the original position.
(like get the faces original offset from the empty> when the empty rotates you know how the face is transform)

edit: we can store the vertex location relative to partent bone (or more than one and average them)

Okay, so empties are parented to the bones, so when the bones twist, the empties rotate or translate accordingly, that makes sense. I don’t know what you mean by “shape objects,” and I don’t know what the ultimate goal is with parenting these empties to the bones.
If I confine the spider to only moving between empties, then there’s no game because players no longer have any freedom to move as they choose.
So imagine everything about the game is the same as it is now, except it has an extra complicated deforming object. If I have the spider parented to the empties, then all of a sudden the spider is going to move along with those empties even when it is many units away from them and fall through the level or collide with it in weird ways. The goal is to allow the spider to walk from the landscape to a deforming object and stick to it as it would the landscape staying perpendicular to any face or vertex it walks on, without flying off regardless of the speed of deformation.
Perhaps if I parented an empty to every vertex on a mesh I could do something with that. It would be tedious work, but it might be an improvement on whatever concept you’re suggesting, that’s more how I would animate it manually.

ok so armature skinning is using a bone, and moving a vertex relative to that bone

here instead we parent a empty to the bone and move a object every frame to match bone position using the empty.

the ray hits the shape object, gets a local and sticks the spider to the shape.

from here it’s some more rays to decide how to transfer across shapes or into the air etc.

here is a example of updating the animated objects shape objects
update_shapes.blend (500.4 KB)

if I get a minute I will add the part to move the spider to match the shapes movements using local

Don’t quite know what you mean by “skinning,” but no it’s not using one bone, it’s many bones, maybe that’s where the confusion is.

take the initial local compared to X bones and average it by weight = yields vertex position

but this should be a approximation not 1x1 real physics - reinstancePhysicsMesh() - is basically like teleportation to the next position of the armature.

a more realistic sim would need to isolate the faces that would move near the player, and cast rays from where it was, to where it would be* ( CCD )

it’s just too much brute force required.

you can move the approximation shapes and even scale them to match the bones.
moving local to these objects will appear visually the same* and use like 100 times less resources.

update_shapes2.blend (659.4 KB)

Cool. But what if one want “spider” to move around animated object in all directions? Not only forth but left\right and rotate itself moving in all directions staying sticked to object not falling down?

Am trying to learn how to code riding animals without python. Just because am not good at coding. If you guys know what script I need for logic to make a ridable Animal. that would be great.