#Having transform, rotation, vector, collision and logic problems

1 messages · Page 1 of 1 (latest)

surreal folio
#

Hi.

So in my game, the player will be crawling through tight tunnels where he might need to twist and turn and push to get through.

Game is in first person and I need vision of the arms including the shoulder.

I am using an IK system to determine where the palm (hand bone) should go and the rest of the arm follows.

However, I can't control how the rest of the arm behaves, other than the hand bone. My elbows and other joints can clip through walls and I don't want that. It's not just that. I need some kind of reacting to collision if it happens where I don't want it.

When it works, it looks decent, I need to make edge cases look good too.

I have attached an image with 4 panels, showing 4 potential problems (there are many more possible instances though). On each panel is the character with the hands and a blue dot representing where I want the hand (palm) to land.

In the first panel, the hand want to go straight up, through a wall. The dot should actually be a bit more to the left, on the wall edge. Now, the hand should clip through the wall to get there but it shouldn't just stop on collision either. I want it to roll forward. Perhaps move it along the wall edge or change the target location and keep moving it to the left until the hand is cleared to pass.

In the second panel, the hand can reach the dot but will likely induce some clipping in the elbow or along the forearm. The best case scenario there would be to stop it from stretching once it hits the elbow.

In the third panel (I should actually have the player higher up so that it's actually possible to reach the blue dot physically) everything but the palm will surely clip through the wall. In this case, I'd want to raise the elbows as much as possible so that the whole arm is clear of the wall.

In the fourth panel, ideally I'd have the hand follow the slope along with the elbow but raising the entire arm just so the elbow could clear the slope would work too.

Charact. limit hit, more info in comment

#

How would I code it in a way where I know how I'm trying to solve the collision? For example, let's say I'm reaching straight in front into a wall.

I could get the reflection vector of the surface normals or have multiple sensor colliders to determine if I'm hitting it dead on or at a steep angle. If head on, I stop on it or below it. If steep angle, I roll along the wall edge.
What about the other cases?

I've also considered adding character controllers to each of the hand ik target. Yes, I know it sounds goofy, but they have an in built functionality of rolling based to slope steepness and also vertical stepping values. Maybe that could help.

Also, to be clear, I've been stuck on this for some time. I've tried multiple ways to solve this problem; the latest being puppetmaster. In theory, it does all I want, but as anything that uses physics, it just jitters and rolls and twists uncontrollably. I've been toying and tweaking with puppet master for a bit now, but I'm starting to doubt that I can do this with it.

So my next approach is really trying to do everything via code but I don't know if it's realistic to try and solve every edge case like this.

What do you guys think? Any suggestions?

surreal folio
#

Bump

haughty prism
#

I think half of it is a game design issue.
Mainly, how do you want to proceed, if the arm can't physically fit or unfold in a specific pose? Completely block the player from proceeding in that direction? Or make some visual compromises?

Most games would probably either making this feature heavily scripted/prerecorded animations and or design the environment specifically for the climb.

If you're going with blocking the player movement, you could probably do it easily by adding several colliders to the arms and adding some extra logic to the IK solvers.

You could also control the pole/bend target/twist target of the IK for extra degrees of freedom(to avoid elbow collision). Combine with some kind of PID controller to adjust the elbow rotation automatically.

Beyond that, you'd either have to limit the player movement, produce unnatural arm poses or have some clipping.

#

Also, I'm pretty sure that what you're trying to achieve is an ongoing robotics problem, so perhaps look in the robotics field for more ideas. But don't expect to get a perfect solution.

surreal folio
# haughty prism I think half of it is a game design issue. Mainly, how do you want to proceed, i...

No. I want to have a collider that stretches shoulder width. I am currently using a character controller but I should change that, cause it can't rotate and I can't have rotation blocking.

Anything that collides other than the controller collider should be able to pass. A head will have a collider but it should duck and drag.

Arms should twist or bend to pass through. I have animations that pull me forward, I just need to have some kind of reaction to the terrain for them.

Puppet master should, in theory, do exactly that but it just doesn't work well because like all things that are physics based, it's more comical than anything.

Also, with puppet master, the hands get stuck behind the player and it's not really puppet master's fault that they can't get unstuck because it doesn't "know" that the body should contort to let the arms through.

Yeah, I'm aware this is complicated. No one has really been able to help me.

I'm not sure what you're talking about with the pole and PID controller tho

vast pawn
surreal folio
haughty prism
# surreal folio No. I want to have a collider that stretches shoulder width. I am currently usin...

If you don't intend to use IK, then ignore the PID controller thing.

However, if you are fine with the hands bending and twisting in unnatural angles, then it should be quite a bit easier.
I'm not sure what "puppet master" is, but I assume it's an asset implementing active ragdolling. If so, you should be able to get closer to the desired effect by tweaking it slightly:

  • if it's relying unity physics, you could try using a physics material with 0 fricrion on the hand and cave colliders. This should let the colliders slide more in the desired direction. If it doesn't use unity physics, you might need to implement that logic in code.
  • if stretching is fine, you could make the colliders ignore collision after some threshold. They would clip through stuff to get to their rest position, but it's likely gonna be outside of view.

Also, might be mistaken, but it sounds like you're letting the player move the character body directly(you said that the hands get stuck behind). This is a poor choice for such a mechanic. You should let the hands drive the character motion instead. Or maybe some kind of virtual point that is calculated based on the positions of both hands. Then just let the body drag/crawl owards that point in whatever way you're moving it.

surreal folio
# haughty prism If you don't intend to use IK, then ignore the PID controller thing. However, i...

You have some good ideas here.

Firstly, it's not just about sliding with ouopet master. It's all kinds of shaking and jiterring.

Also, I do use ik from animation rigging.

Disabling collisions out of view is a very interesting idea. I hadn't thought about it somehow. That would solve one puppet master issue, but not the stability tho.

Having the hands be the motor is also an interesting idea but I don't think it would work. The arms are always supposed to go through in whichever way possible and the body collider is wider, so I could have plenty of cases where arms fit but body doesn't

haughty prism
# surreal folio You have some good ideas here. Firstly, it's not just about sliding with ouopet...

If it's shaking and jittering most of the time, it sound like a bug or incorrect setup.

If you do use IK, then consider what I mentioned: control the bend target(apparently it's called a hint in unity animation rigging package) and the IK target manually. As well as maybe using a PID controller(Google it if you don't know) to interpolate the arms to an optimal position/pose.

Lastly, you don't need to go to extremes. Even if you mainly use hands as the motor, you can still incorporate the body influence into system. If the body is stuck and can't get through, apply relative damping force to the "motor" to prevent it from going too far ahead.