Clamp character rotation, from cameras forward vector

I’m controlling my payers head directly and rotating my characters body another way. I want to limit the characters body rotation so the body and head stay realistic.

So How Do I make sure the body can’t rotate YAW. beyond -90/90 degrees from characters natural head position EG: Camera look

Are you using control rotation for any of them?

NOPE.
Just rotating the mesh for now.
I had the right ideas here Trying to do it from the actual head bone, but my brain blue screened .

Pff, was hoping for a quick camera manager fix. :cry:


Not sure how the whole thing works (event though your description is pretty clear) - as in, where the input is coming from but the most straightforward way is to accumulate a rotator (only yaw, perhaps?) in a variable, clamp it and then set rotation:


If you’re looking for relativity, the (inverse) transform nodes will help:


Another way to check whether 2 vectors are aligned is the dot product (degrees are optional here):


There’s a bunch of relative components attached to one another in your setup, wish I had the time to replicate exactly that and offer a plain solution. Hope the above helps a bit.

2 Likes

Excellent!

So I tried this first method that you can see connected in the picture and it works.
But its only working initially, For instance if my character is looking in x world direction then. the body seems to get limited to -90 / 90 of that and when I look left or right its still stuck :frowning: . The above bit I commented as 1-1 in red works perfectly as it should! but it allows the body to invert facing backwards to the head which is an impossible rotation for a human head Not what I want. Im basically trying to prevent the body from facing backwards when my hands go behind me, The torso arrow is always pointing to between the hands and thats what Im using to tell the body where to face. The green arrow is there Im looking and thats what I want the body rotation clamped to .

EG: if I move my hands back and the body rotation gets clamped, but then I rotate my head towards my hands I want the body to be able to rotate more becaue the limit has changed.


Have a look at my post here:

There’s an example of how to clamp an angle depending on the facing direction.

1 Like

Wow Lightning response time :exploding_head:
And thanks I believe this was it.