# Wrong documentation

**URL:** <https://forum.playcanvas.com/t/wrong-documentation/41378>\
**Category:** Suggestions & Feedback\
**Created:** [November 25, 2025, 10:56am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378 "2025-11-25T10:56:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![DJ\_Coco](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@DJ\_Coco](https://forum.playcanvas.com/u/DJ_Coco)\
**Post date:** [November 25, 2025, 10:56am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/1 "2025-11-25T10:56:26Z")

</div>

![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/1/e/1e9494f21c497fa43401ee176ca1863b10dcb17a.png)  
The documentation for Screen.priority seems wrong. It says the range is 0-255 but the values -128 to 127 work for me while anything below/above does not.

Seems like someone confused their signed integer for an unsigned one.

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [November 25, 2025, 11:04am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/2 "2025-11-25T11:04:31Z")

</div>

Works fine for me. Are you sure you are setting it up correctly? Can you make a simple example project that demonstrates the issue?

---

<div class="post-metadata">

**Author:** ![DJ\_Coco](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@DJ\_Coco](https://forum.playcanvas.com/u/DJ_Coco)\
**Post date:** [November 25, 2025, 11:10am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/3 "2025-11-25T11:10:57Z")

</div>

[PlayCanvas | HTML5 Game Engine](https://playcanvas.com/editor/scene/2330591) (wpw branch needs to be selected)  
Launch and click Wirtschaftspark Walgau on the left followed by selecting any of the floors (OG2 for instance)

The screens that pop up are being sorted by distance and their sorting priority is logged below.

See script markerScreen.js which handles the sorting

```javascript
this.entity.screen.priority = pc.math.clamp(127 - pc.math.roundUp(this.entity.getPosition().distance(this.camera.getPosition()) * 2, 1), -128, 127);
//this.entity.screen.priority = pc.math.clamp(255 - pc.math.roundUp(this.entity.getPosition().distance(this.camera.getPosition()) * 2, 1), 0, 255);

```

Comment out the line that works and replace it with the presumably intended version (0-255 range) below and notice how the sorting changes when trespassing 127.

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [November 25, 2025, 11:31am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/4 "2025-11-25T11:31:36Z")

</div>

Well, firstly, this is a private project, so can’t see it. Secondly, other users can’t see branches in public projects.

Can you make a blank project with just 2 screen elements? Just some colored boxes on top of each other.

---

<div class="post-metadata">

**Author:** ![DJ\_Coco](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@DJ\_Coco](https://forum.playcanvas.com/u/DJ_Coco)\
**Post date:** [November 25, 2025, 11:35am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/5 "2025-11-25T11:35:54Z")

</div>

My bad, I thought the project had been made publicly available again.

I will try to isolate the issue in a public project later.

---

<div class="post-metadata">

**Author:** ![DJ\_Coco](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@DJ\_Coco](https://forum.playcanvas.com/u/DJ_Coco)\
**Post date:** [November 25, 2025, 11:57am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/6 "2025-11-25T11:57:37Z")

</div>

[https://playcanvas.com/editor/scene/2370932](https://playcanvas.com/editor/scene/2370932)

Zoom out to see the issue. The issue is when some screens are above 127 and others are below.

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [November 25, 2025, 12:41pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/7 "2025-11-25T12:41:19Z")

</div>

Hmm, there is something fishy going on indeed. @mvaligursky any ideas?

Also, the Editor’s field for priority on a screen component is not allowing to set it larger than 127 for some reason. That’s a bug, but shouldn’t be related to this (probably?). I will create an issue for that.

Edit:

> <https://github.com/playcanvas/editor/issues/1560>
>
> Editor doesn't allow setting a screen priority larger than 127, although up to 2…55 should be allowed.
> 
> \<img width="416" height="220" alt="Image" src="https://github.com/user-attachments/assets/36d88858-9b76-4c8f-8a0a-58ad1d91f884" /\>

---

<div class="post-metadata">

**Author:** ![mvaligursky](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mvaligursky/32/11681_2.png) [@mvaligursky](https://forum.playcanvas.com/u/mvaligursky)\
**Post date:** [November 25, 2025, 1:34pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/8 "2025-11-25T13:34:20Z")

</div>

no idea, not familiar with that bit of code at all … but it’s likely an engine bug here

---

<div class="post-metadata">

**Author:** ![mvaligursky](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mvaligursky/32/11681_2.png) [@mvaligursky](https://forum.playcanvas.com/u/mvaligursky)\
**Post date:** [November 25, 2025, 1:48pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/9 "2025-11-25T13:48:55Z")

</div>

I think the solution is:

- leave Editor as is, only support values 0…127
- update engine to match

problem is that top 8 bits of 32bits are used to store this, but bit 31 is a sign bit, and all goes incorrectly when this is used.

---

<div class="post-metadata">

**Author:** ![mvaligursky](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mvaligursky/32/11681_2.png) [@mvaligursky](https://forum.playcanvas.com/u/mvaligursky)\
**Post date:** [November 25, 2025, 2:04pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/10 "2025-11-25T14:04:47Z")

</div>

added the change in the engine here to make sure only 0…127 range is used:

> <https://github.com/playcanvas/engine/pull/8180>
>
> \## Overview
> 
> Fixes a sorting issue where Screen components with priority value…s \>= 128 would render incorrectly due to signed integer overflow when the priority is shifted into the drawOrder value.
> 
> \## Problem
> 
> When Screen.priority values \>= 128 were used, the bitwise left shift operation (\`priority \<\< 24\`) would set bit 31 (the sign bit), creating negative drawOrder values. This caused sorting comparisons to fail when mixing screens with priorities above and below 128, resulting in incorrect render order.
> 
> \## Solution
> 
> Changed the valid priority range from 0-255 to 0-127, preventing the sign bit from ever being set. This ensures all drawOrder values remain positive and sortable.
> 
> \## Public API Changes
> 
> \*\*Breaking Change\*\*: \`ScreenComponent.priority\` valid range reduced from 0-255 to 0-127
> 
> \- Values outside the range 0-127 will trigger a debug assertion
> \- Values are automatically clamped to the valid range (0-127)

---

<div class="post-metadata">

**Author:** ![DJ\_Coco](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@DJ\_Coco](https://forum.playcanvas.com/u/DJ_Coco)\
**Post date:** [November 25, 2025, 8:43pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/11 "2025-11-25T20:43:40Z")

</div>

Cool to see it addressed this quickly. Was anything changed beyond the documentation/clamping?

Also, are negative integers taboo? I didn’t notice anything breaking from -128 to 0. Asking because when calculating sorting order by distance having more values available is handy since floating points are unsupported.

---

<div class="post-metadata">

**Author:** ![mvaligursky](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mvaligursky/32/11681_2.png) [@mvaligursky](https://forum.playcanvas.com/u/mvaligursky)\
**Post date:** [November 25, 2025, 9:39pm UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/12 "2025-11-25T21:39:24Z")

</div>

it would break if there were both positive and negative values at the same time. So we avoid negative values.

you could add your floats to array with index, sort array, and assign indices or so, to avoid the limitation.

---

<div class="post-metadata">

**Author:** ![LeXXik](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lexxik/32/6953_2.png) [@LeXXik](https://forum.playcanvas.com/u/LeXXik)\
**Post date:** [November 26, 2025, 9:41am UTC](https://forum.playcanvas.com/t/wrong-documentation/41378/13 "2025-11-26T09:41:49Z")

</div>

> Was anything changed beyond the documentation/clamping?

No other changes. The values are (after release) hard clamped to 0-127 now.
