# Get 2D screen coordinates from a 3D object translation

**URL:** <https://forum.castle-engine.io/t/get-2d-screen-coordinates-from-a-3d-object-translation/1934>\
**Category:** 3D\
**Created:** [June 6, 2025, 2:19pm UTC](https://forum.castle-engine.io/t/get-2d-screen-coordinates-from-a-3d-object-translation/1934 "2025-06-06T14:19:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Recongalina](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/recongalina/32/1530_2.png) [@Recongalina](https://forum.castle-engine.io/u/Recongalina)\
**Post date:** [June 6, 2025, 2:19pm UTC](https://forum.castle-engine.io/t/get-2d-screen-coordinates-from-a-3d-object-translation/1934/1 "2025-06-06T14:19:02Z")

</div>

Hi all!

I made speech bubbles as TCastleUserInterface class. Now I want to make this bubbles follow to the 3D character across the screen.  
As I understand, I need to take TVector3 coordinates, for example, of the character’s top point and translate those coordinates into screen TVector2 coordinates. But how can I do this?

PS: This question has probably already been raised on the forum, but I couldn’t find the relevant topic.

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [June 6, 2025, 2:56pm UTC](https://forum.castle-engine.io/t/get-2d-screen-coordinates-from-a-3d-object-translation/1934/2 "2025-06-06T14:56:38Z")

</div>

The [TCastleViewport.PositionFromWorld](https://castle-engine.io/apidoc/html/CastleViewport.TCastleViewport.html#PositionFromWorld-TVector3-) is what you need 🙂

We have a demo that shows using it, to display a UI element (`TCastleLabel`) at a position that exactly matches the position of a 3D object inside a `TCastleViewport`, see [examples/viewport\_and\_scenes/position\_from\_world/](https://github.com/castle-engine/castle-engine/blob/master/examples/viewport_and_scenes/position_from_world/).

Note: An alternative would be to make speech bubbles using meshes with text using TCastleText. Then you can put speech bubbles inside `TCastleViewport`. That’s the approach we followed in the end in “The Unholy Society” ( [Unholy Society](https://michalis.xyz/unholy/) ), after a bit of experimentation. It allowed to use Blender to design speech bubbles shapes, although adjusting the size of these predesigned bubbles to fit the text precisely was some additional work. Making speech bubbles as you describe, using `TCastleUserInterface`, would be probably my first choice nowadays, as then you can use our UI system sizing properties (to adjust to parent/children in various ways).

---

<div class="post-metadata">

**Author:** ![Recongalina](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/recongalina/32/1530_2.png) [@Recongalina](https://forum.castle-engine.io/u/Recongalina)\
**Post date:** [June 8, 2025, 2:39pm UTC](https://forum.castle-engine.io/t/get-2d-screen-coordinates-from-a-3d-object-translation/1934/3 "2025-06-08T14:39:03Z")

</div>

Thanks for Your help! It working!  
I just little didn’t scroll through the examples to the right ones 🙂
