Turrets and Scrolling oddity

0 favourites
  • 2 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Here's an example capx


    I have an object on layer 1 with no parallax that is acting like a turret.

    Its target is an object that is moving through the scene with a scroll to behavior on it.

    The turret object successfully tracks and shoots at the target but after the target starts to move away and the scroll to starts tracking , while "visually" it appears within range of the turret, the actually X.Y of the target is outside of it, and therefore can't shoot at it anymore.

    SO..... is there a way to keep the turret object able to keep aiming at its target with a 2 layer system like this? or do i just need to put them on the same layer and keep them parented to the camera so that all objects update together and therefore never get to far apart?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So upon further investigation it appears its related to the difference in parallax between layers and needing to dive into using LayerToCanvas

    Here's an example tutorial / capx that really helped me understand it better.

    https://www.scirra.com/tutorials/1167/l ... er-example

    I dont know if its the easiest/cleanest solution but heres one workaround for my setup.

    Create a dummy object on the 0,0 parallax layer and position it overtop of the target using the code from the example. eg:

    set dummy target position = CanvasToLayerX("UI",LayerToCanvasX("level", Player.x, Player.y) ,LayerToCanvasY("level", Player.x, Player.y))

    this creates an object for the turret to aim and shoot at on the same layer as itself, but it follows the position of the object on the layer below.

    again, if anyone knows an easier or cleaner way around this, please let me know.

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