How do I set a sprite on a 2D layer to perfectly match an object on a 3D layer?

0 favourites
  • 4 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • With a mouse, I can do Mouse.X("LayerName")

    However, I can't do this with any other object.

    Say I want a special effect to occur at the position of a sprite on a 3D layer. At the moment, my camera zooms in on an object, almost centralising it to the screen. The effect is then generated, but it's created at the position of the object... based on its position on the canvas.

    So if the object is 100 pixels from the edge of the screen, the camera will zoom in on it, then the effect spawns on the 2D layer, but appears 100 pixels from the edge of the screen, rather than on the object.

  • you need to use layerToCanvas() and canvasToLayer().

    These formulas will be something like this:

    CanvasToLayerX("Layer2", LayerToCanvasX(CursorSprite.LayerNumber, CursorSprite.X, CursorSprite.Y), LayerToCanvasY(CursorSprite.LayerNumber, CursorSprite.X, CursorSprite.Y)

    CanvasToLayerY("Layer2", LayerToCanvasX(CursorSprite.LayerNumber, CursorSprite.X, CursorSprite.Y), LayerToCanvasY(CursorSprite.LayerNumber, CursorSprite.X, CursorSprite.Y)

    there's also this suggestions to make these calcualtions easier:

    https://construct23.ideas.aha.io/ideas/C23-I-71

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • just realized you are talking about 3d, the 3d camera has its own layer to canvas and canvas to layer.

    3dCamera.canvasToLayerX etc.

  • That got it, thanks!

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