How do I keep layertocanvas consistent when scaling window?

0 favourites
  • 3 posts
  • I'm experimenting with a 3D game using the 3d shape and 3d object tool, but one issue I've run into is displaying relevant text matching the perspective of the camera. I'm working around this by having a UI layer that displays the text.

    I have 2 different types, text for when you mouse over an object, and text that pops up next to a player when they speak. The first one was easy, I just set the position to Mouse.X/Y("UI"). The second one I'm having trouble with.

    For the second one, I'm using LayerToCanvasX/Y("Game",Animals.X,Animals.Y), and sometimes it works if the window is just the right size, but as soon as I resize the window or go fullscreen the text is severely offset. I'm assuming this is because canvas coordinates change because there are technically more pixels in the window, but is there a formula I can use to keep this text consistent? Thanks!

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't have any experience with 3D yet, but normally to convert coordinates between two layers you need these two expressions:

    Set X to CanvasToLayerX("UI", LayerToCanvasX("Game",Animals.X,Animals.Y), LayerToCanvasY("Game",Animals.X,Animals.Y))

    Set Y to CanvasToLayerY("UI", LayerToCanvasX("Game",Animals.X,Animals.Y), LayerToCanvasY("Game",Animals.X,Animals.Y))

  • I don't have any experience with 3D yet, but normally to convert coordinates between two layers you need these two expressions:

    Set X to CanvasToLayerX("UI", LayerToCanvasX("Game",Animals.X,Animals.Y), LayerToCanvasY("Game",Animals.X,Animals.Y))

    Set Y to CanvasToLayerY("UI", LayerToCanvasX("Game",Animals.X,Animals.Y), LayerToCanvasY("Game",Animals.X,Animals.Y))

    Ahhh thank you! This worked perfectly <3

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)