Info
This post was imported from a personal note. It may contain inside jokes, streams of consciousness, errors, and other nonsense.
I had refactored the tentacle segments so that each one knew its parent segment and so could automatically calculate its pivot point. The problem with this became immediately obvious when I started to work on being able to move the tentacle base. I no longer had any way to move the segments around independently of the location of the base.
I should’ve known better. I’ve been taught this lesson before. Having models that are too smart often ends up making things more difficult, not easier. So back to dumb Tentacle Segments, now with more accessors so the pivot and endpoint PVectors are well-protected.
I did add member functions to update the endpoint based on the pivot, angle, and length and to update the pivot based on the endpoint, angle, and length. That reduces code duplication length * cos(angle), length * sin(angle)
but still leaves the control of when to do it and in which direction to the Tentacle class. Cool.
It was a little tricky to get it working again but the code is actually quite a bit cleaner with the new accessors.
One issue I’ll have to come back to is detecting when a tentacle segment has released the surface it was fixed to. Detecting when it needs to release and also deciding when to release.
Now, back to shifting the base.
Okay, so I got it working really well if none of the segments are fixed. I also haven’t tried moving up and down but feels like that should work, too.
I kinda wonder if I can do something about how rigid the tentacle seems, particularly when moving from the left side of the screen towards the center.
But I got other problems.
Fixed segments are looking horrible right now. Here’s what I mean:
It looks like IK is not getting a very good solution. Everything still happens relative to the base so the so-called “fixed” points get shifted by the error from the IK.
That’s… not great. But I guess it makes sense. I would much rather some jitter around the base. Actually, I would much rather the IK works well enough that the error is less than a pixel and you don’t see the effect at all. Failing that _then_ I would rather see the base of the tentacle jitter around the actual player location. I think. It might look bad if the first couple segments of tentacle seem to be vibrating but I’m imagining that if there’s some octopus head artwork covering where the tentacle begins then having some jitter there should be fine.
What happens if I up the iterations on the IK?
Okay, that’s weird. Almost no difference after changing from 20 iterations to 1,000 iterations.
A couple possibilities:
- Is something wrong with your IK implementation?
- Do the better IK algo. That CCD one you were using.
One more thing. The two fixed circles aren’t moving. Good. But the circle to the right of it isn’t moving relative to them either. The line between those two belongs to the fixed circle on the left. So actually, I can rotate the first fixed segment.
One more one more thing. The unfixed segments after the fixed segments are gonna need some IK treatment as well. They shouldn’t just freeze up like they are now.