Turrets and Scrolling oddity

Discussion and feedback on Construct 2

Post » Fri Oct 03, 2014 9:01 pm

Here's an example capx
https://db.tt/QmP6yRL7

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?

Thanks
B
82
S
39
G
15
Posts: 982
Reputation: 16,712

Post » Fri Oct 03, 2014 10:28 pm

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.
B
82
S
39
G
15
Posts: 982
Reputation: 16,712


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests