Skip to main content

Tentacle Collision with Surface

·385 words·2 mins

Info

This post was imported from a personal note. It may contain inside jokes, streams of consciousness, errors, and other nonsense.

Neat problem. The segments will end up rotating in different directions so that the tentacle overlaps itself on the surface.

Starting frame: image

About to collide: image

So far so good. The rest of the tentacle segments are rotating until they hit the surface. This one will be a problem, however. image

It rotates in the wrong direction. image

I need something to tell the rest of the segments which way to turn.

Ever since we started moving the tentacle segment by segment from tip to base I’ve been thinking it’s like we’re modeling instructions that run from the base to the tip. Might be good to create a class for that. This way, I can handle the tentacle is colliding with different things at different points or the player changing their minds and issuing new commands while previous commands are still being processed by the tentacle. There will probably also be a way to cancel commands.

Okay, fixed it: image image image Okay now, the last segment is actually closer to the target direction if it rotates clockwise. image But now it rotates counterclockwise. Perfect.

Problem I’ve found is with my collision handling. It assumes the segments start off from a non-collided state and works from there forwards until it collides again, then takes the angle from just before the collision. image It doesn’t handle situations like the above very well. Some of the trailing segments have been pushed into the ground. Yes, I will fix that by adding collision detection during the phase where the trailing segments are dragged behind the currently rotating segment. But. That’ll hide issue with my collision detection… although, maybe I _should_ be able to assume that the collision handling is working from a valid previous state. Hrm.

Okay, I’ll fix the dragged segments instead.

image This works. The trailing segments get pretty jumbled up but I think I’m okay with that. It doesn’t seem unexpected.

Here’s a demo: image

This is a really nasty, ugly animation but it gives an idea of what I’m going for: image

I’ll need to have the points on the surface be fixed somehow and let the other stuff move relative to the fixed segment closest to the base. Phew. That’s gonna be interesting.