How do I track the X&Y for a parallax object

0 favourites
  • 5 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • I have an object that's somewhere outside of my project.... I would like to track it's X&Y exactly, however because it has a different parallax than the 'arrow' i'm using to point at the object, the arrow reads a different X & Y coordinate, showing it off. When it's not zoomed in... it's fine. When you zoom in (layout scale) it screws up, because of the parallax.

    Can anyone help me out? It's 5 in the morning... I've been up all night... probably the reason I'm not figuring this out.... also the reason this may not make any sense to anyone... hence the upload.

    [attachment=0:3kvi0yrc][/attachment:3kvi0yrc]

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You'll need to convert Layer Co-ords to Canvas Co-ords.

    [attachment=0:58c5xhrm][/attachment:58c5xhrm]

    I did it 2 ways.

    Instance variables for the drag-able box that covert the x pos & y pos on the layer to canvas and store them as instance vaviables. This was so you can see the expression more clearly.

    And a toggled disabled action that does it all in one expression but is a bit long and maybe hard to understand what's going on.

    The expression you need is under System>Layers>LayerToCanvasX & LayerToCanvasY.

  • Awesome.... figures I would have missed that one. Thanks!

    With that, I also figured out how to change the position too:

    Set X- CanvasToLayerX("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))

    Set Y- CanvasToLayerY("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))

    Thanks again!

  • Glad you sorted it.

    I updated the capx but you beat me to it. I'll post the capx anyway for anyone else who wants to achieve the same thing.

    [attachment=0:d32wzg6w][/attachment:d32wzg6w]

  • this is great. thanks.

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