# BoneLookController Attitude limitation problem

**URL:** <https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151>\
**Category:** Questions\
**Tags:** bone\
**Created:** [May 26, 2023, 5:52am UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151 "2023-05-26T05:52:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiehangyun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiehangyun/32/30777_2.png) [@xiehangyun](https://forum.babylonjs.com/u/xiehangyun)\
**Post date:** [May 26, 2023, 5:52am UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/1 "2023-05-26T05:52:59Z")

</div>

[gaze | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#1B1PUZ#145)  
In this case, I wanted to set Yaw less than -160 and greater than 160 to limit the lateral deviation of the eyeball, but I couldn’t?  
The BoneLookController receives the minimum and maximum values of the options passed in, if they are greater than the minimum and less than the maximum.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 26, 2023, 3:59pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/2 "2023-05-26T15:59:00Z")

</div>

hmmm you want to limit the angle of the eye bones so the pupils never disappear right? @bghgary @Evgeni_Popov any idea how can this be done?

---

<div class="post-metadata">

**Author:** ![xiehangyun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiehangyun/32/30777_2.png) [@xiehangyun](https://forum.babylonjs.com/u/xiehangyun)\
**Post date:** [May 26, 2023, 5:53pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/3 "2023-05-26T17:53:05Z")

</div>

Yes, I would like to limit the pupil yaw value, yaw \< -160 || yaw \> 160, but now its rules don’t seem to allow.  
Modifying adjustYaw didn’t get the effect I wanted, causing the pitch to move in the opposite direction.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2023, 10:48am UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/4 "2023-05-27T10:48:13Z")

</div>



---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2023, 1:03pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/5 "2023-05-27T13:03:56Z")

</div>

In your case, you need the yaw value to be either between [160°,180°] or [-180°,-160°]. Or, if using the absolute value of yaw, it is simply [160°,180°].

I have created a PR that allows you to use the absolute value of yaw instead of yaw when checking the constraints:

> <https://github.com/BabylonJS/Babylon.js/pull/13911>
>
> See https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem…/41151

When the PR is merged, this PG will work (look for `useAbsoluteValueForYaw` in the `options`):

> **[Babylon.js Playground](https://playground.babylonjs.com/#1B1PUZ%23140)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2023, 1:03pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/6 "2023-05-27T13:03:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![xiehangyun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiehangyun/32/30777_2.png) [@xiehangyun](https://forum.babylonjs.com/u/xiehangyun)\
**Post date:** [May 27, 2023, 3:07pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/7 "2023-05-27T15:07:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/b/eb423c68764ffcfae9ee17dd40d3f484b5f8627f.png)  
Thanks for the reply, and the PR, but there are still issues with using absolute values.  
I use a diagram to describe the problems that may arise.  
Because the yaw value is a ring, can we determine whether the range of the yaw limit is above or below the ring by judging the size of min versus max?  
Here are some of my thoughts.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2023, 3:35pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/8 "2023-05-27T15:35:35Z")

</div>

The PR will make your PG work the way you want it to, so that’s at least a step in the right direction 🙂 .

I think the most general solution would be to be able to define several ranges for the yaw constraint (and pitch, for that matter) - [160°,180°] + [-180°,-160°] in your case. That’s what I tried at first, but I’m not familiar enough with the code and how it works, so I tried the “absolute value” route and was pleased to see that it worked!

---

<div class="post-metadata">

**Author:** ![xiehangyun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiehangyun/32/30777_2.png) [@xiehangyun](https://forum.babylonjs.com/u/xiehangyun)\
**Post date:** [May 27, 2023, 4:39pm UTC](https://forum.babylonjs.com/t/bonelookcontroller-attitude-limitation-problem/41151/9 "2023-05-27T16:39:00Z")

</div>

> [@Evgeni\_Popov](#):
>
> I think the most general solution would be to be able to define several ranges for the yaw constraint (and pitch, for that matter) - [160°,180°] + [-180°,-160°] in your case

This should be the perfect solution.
