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

own.world Position = own.worldPosition.lerp(someEmptyParentedToArmatureBone.worldTransform*Vector(offset))

use empties parented to the webs bones, and lerp between them at a rate based on distance/time

I still don’t understand this. If I use empties to guide a path, then there’s no game, the player can’t control the spider cause they are stuck to a path. Out of all the physics settings, is there honestly no way to simply increase friction or stickiness so the spider doesn’t fly off of something moving too fast? It doesn’t soak up too much processing to me, I just need the spider to actually stick now.

This is totally an other question, but there is a way for that indeed.

cast a ray down from your player and detect what’s beneath him and act according to it

from bge import logic

def stick_to_it(cont):
    
    own = cont.owner
    vector = own.worldPosition - own.worldOrientation.col[2]
    ray = own.rayCast(vector, own,0)
    
    if ray and ray[0] is not None:
        if 'stick_to_it' in ray[0]:
            if ray[0]['stick_to_it']:
                own.localPosition = ray[0].localPosition.copy()

The above just do exactly that: stick to object. Add an Always(true pulse)-python-module->scriptname.stick_to_it. add a property on the object where you want the player to stick on called: stick_to_it, make it boolean.

The script will cast a ray down (-z axis), if the ray is true it checks a property, if that property is in the object then it checks the state of that property, if the state is true, it will set the player position the same as the spiders position, thus moving spider and player will move with it.

Or an other solution is using obj.setParent(spider), wherever the spider goes parented objects follow it.

yeah, like what cotaks said.

detect collision, use it to get child shape object, move spider location based on local of obj.

https://youtu.be/2Uc0bxSGo4E that is how I move here.

actor.worldPosition = (lastObj.worldTransform*lastLocal)+own.worldLinearVelocity
raycastAgain(storeLocal/obj)

Thank you very much for the script, I will try it.

So if casting a ray down isn’t already what the spider uses, how exactly does it get it to stick at all currently? Getting one object to stick to another as it deforms is something I’ve been trying to do in animation for months, does it only work in BGE? An object isn’t necessarily moving at all, just deforming from an armature.
I see no boolean option for properties, do I apply the property to the spider or the object I want it to stick to?

  1. any armature needs a empty at the center of it’s bone parented to it
  2. child shapes that match the mesh shape are moved / reparented each frame
for  entry in boneList:
     BoneShape = entry[0]
     BoneEmptry = entry[1]
     BoneShape.removeParent()
     BoneShape.worldOrientation = BoneEmptry.worldOrientation
     BoneShape.worldPosition = BoneEmpty.worldPosition
     BoneShape.setParten(compoundRootOb)

(this updates the shape of a armature actor each frame and is much much cheaper than re-instancing meshes)

ray = own.raycast(args)
if ray.positive:
    # if the object you hit is compound all child shapes return core object
    # we simplly itterate over the bones in the chain and see whom the hitpoint is closest to
    # we can place the player local to the moving object from here if it's the same as last frame if not
    # store the new shape and new position as last position causes a 1 frame 'lag' as you hop shapes
    # not noticible
    if ray[0] == own['LastObject']:
        localTo= own['LastObject'].worldTransform*own['LastVector']
        local += own.worldLinearVelocity
        own.worldPosiition = localTo
        own['LastObject']=ray[0]
        own['LastVector'] = own['LastObject'].worldOrientation.inverted()*( localTo - own['LastObject'].worldPosition)
    else:
        own['LastObject']=ray[0]
        own['LastVector'] = own['LastObject'].worldOrientation.inverted()*( localTo - own['LastObject'].worldPosition)
    

It’s not parented to any bones, it’s not a child of anything. Child-of doesn’t move something along a deformation, only the transformation of the origin of an object.

your not listening.

empties partented to bones get moved by the bones

we have -

  1. compound root -> armature parents to this (set ‘compound’ to true in physics tab)
  2. emptries parented to armature bones -> armature moves -> empties move
  3. child shapes are parented to root object

each frame-> remove parent child shapes -> move to match bone position -> re-parent to compound root

this is how I have moving actors have accurate phyiscs / foot strikes in bge.

however you don’t even need the compound parent trick here, just move the shapes to match where the armature is.

Here is my take on: walking on animated objects

If the empties are parented to the bones, then the bones control them, they don’t control the bones. I don’t understand what you mean by shapes, because you could be referring to shape keys which I have never used for anything. If I don’t need the parent child thing which I don’t even know how it works, why are you suggesting it?

But can that block walk around the edge of the animated slab and to underneath it while sticking to it? What is the mechanism that the spider uses to accomplish that?

Last edit i do to the blend,

  • added planet gravity to it, so now you can walk upside down without falling of.

But you need a good entry point in order to activate it, it wont work if you try to jump on a planet for example from the bottom, you need to add a bit more code to it, but that is up to you, i provide you with an example.

you can use a plane with your target property with a box without it.

stick the plane to one side of the box, move it out slightly

hitting the plane w/the ray will detect it, hitting the box will block it.

make it invisible and stick whatever mesh you want on it w/parenting and no collision.

btw for moving physics items I would not use animation.

I typically move physics hitboxes with logic, animations are purely graphical.

something using IK is obviously easier w/a armature, but there are not many use cases for armatures moving physics colliders beyond animating the physics shape of the actor.

Yeah i’m confused by what he wants as well, it’s either let the spider be able to walk on anything (floor/wall/ceiling/other animated objects) or something that needs to walk on the spider (like baby spiders walking over the mom spider). That’s why i made an example of a player walking it all.

That’s exactly what I want and what I’ve been stating over and over. The spider is supposed to be able to walk on something that deforms. However, with the currently suggested code, it doesn’t, because it flies off if an armature deforms too quickly and it doesn’t actually move with the deformation to stay with the nearest face or vertex as it moves.

I downloaded the spider, added it to my blend, works like how i expected, the spider itself will stick already to surfaces, it even walks around my animated objects. The animation/bones are a bit weird placed in my eyes and it will bug out eventually, but this is the problem of the spider/armature/logic bricks. As i see it the spider does already what you want.

Except that it doesn’t…it’s suppose to stick, but it doesn’t because it flies off when something moves too quickly, and it flies off because it’s not actually “stuck” to the deformed surface, it’s just projecting a ray down and using it as a floor, so if the floor moves out of place then the spider falls in whatever direction the ray was in. All I’m looking for at this point is for the spider to have increased friction or stickiness to whatever surface it’s on.

find area spider is relative to,

if the space moves, move spider relative to motion of object

there is no better way to do this*

you can try and exert forces to stick, but this is folly.

You can’t move the spider like that in-game, and there’s definitely a better way to do it, it just hasn’t been presented yet. Someone mentioned some kind of complex path shape parenting thing but I have no idea what they’re saying and I use empties and child-of constraints all the time.

yeah - totally impossible

:expressionless:

I have already done all this. check minute 1:05