playMaker

Author Topic: Rotate Clamp for NPC Head Look  (Read 167 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 73
    • Acornbringer.com
Rotate Clamp for NPC Head Look
« on: July 01, 2022, 04:23:15 PM »
Hello!

Right now I'm using the Look At action to control where NPC heads are facing when the player is close enough. However, I haven't found any success preventing the NPC heads from spinning all the way around if the player happens to move behind them. I'm not sure why, but getting the head rotation, clamping the value, and setting the head rotation to the clamped range doesn't seem to have any effect. I believe the Look At action is overriding the clamp because if I disable it and rotate the character's head in the scene view, I see the limit taking effect.

In my search, I came across the Clamp Rotation action but was unable to use the Default Rotation variable to offset the character rotation as intended. This seems to be because the object controlled by the actions is the neck joint, which remains at it's default rotation (0, 0, 0) while the character game object may be facing any other direction in the scene. What ends up happening is the constrained angle doesn't move with the NPC character if I were to rotate them causing the head to be constrained relative to the world rather than it's self.

Here is the Clamp Rotation action Topic:
https://hutonggames.com/playmakerforum/index.php?topic=8032.30
I was unable to find the script on GitHub but maybe there's an updated version to this?

I'm struggling to find a solution to this feature so any insight is appreciated!