Collision on layers with different parallax?

Get help using Construct 2

Post » Mon Oct 27, 2014 4:42 pm

i have a starship firing lasers and enemies being shot (all on layer "action").
i also have a layer with collision objects with a different parallax. so far all collision seems to work well. the objects kill the player on collision perfectly.
now i implemented enemies crawling around on the background objects of the other layer,
so they scroll with the same speed as the the objetcs with the different parallax to the action layer. (same object type enemies as i have on layer action)
these enemies kill the player perfectly on collision aswell.
however:
the player fired lasers on the action layer dont collide with the crawling enemies after some time.
it works for about a screen or two, then seemingly as the parallax comes more into effect,
collision between action layer created laser sprites and the other parallax layer enemies stops working.
im sorry for not being able to deliver a .capx for this example, as its hard to strip it down.
before i recreate a similar .capx i´d rather know if:
others encountered similar problems?
is construct not supposed to work this way?
i read that same object types on different parallax layers set collision to brute force within c2,
however i dont encounter any slowdowns, the collision just stops working for the player fired lasers, still works fine for the player colliding...
B
5
S
1
Posts: 4
Reputation: 415

Post » Mon Oct 27, 2014 6:04 pm

Haven't run into this but a debug trick would be to create 2 more instances of your player bullet and set them to the other two layers. They should overlap if you change nothing else and never be seen by player. This isn't efficient but it would at least allow you to rule out the layer question.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Mon Oct 27, 2014 6:50 pm

hmm, thx for the thought chisinfinger, i gave it a try and created laser sprites on each layer:
the laser created (not spawned) on the other layer (parallax 280) at player.x+y) is created way behind the laser on layer action (100.100)
it takes about a screens lenght until it is scrolled out and not seen anymore and just about that point i cant hit the enemy with my still visible laser anymore either

however any other object on that 280 parallax layer is still quite accurately colliding with my original laser from layer action,
its just the object type that aswell is constantly spawned on layer action that remains unaffected by the laser, yet collides with the player...

i thought about other ways to keep my enemies in position to the action layer, but they are walking randomly in both directions and stopping aswell on the other layer,
and are supposed to stay in x-relation to the 280 parallax objects ..
B
5
S
1
Posts: 4
Reputation: 415

Post » Tue Oct 28, 2014 5:48 pm

You need to read up on the system expression CanvasToLayer

here's a tutorial and capx that explains it a bit more

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

The positional data of the objects will be different on each layer because of the parallax.
B
83
S
39
G
15
Posts: 984
Reputation: 16,741

Post » Tue Oct 28, 2014 9:26 pm

thx for the link justifun.
ill have a look into this .-)
right now i solved it by directly spawning the enemy on the other layer as opposed to
spawning it on layer action (parallax 100) and then moving it to the other layer (parallax 280)
keeps working endlessly now, although its still on two different parallax layers.
i moved it to the other layer at first so i wouldnt have to exclude it from the spawning block that contains all other enemies (which are all animations of the same object),
which are all spawning on action
but that was a rather quick operation in the end and works lika a charm so far.
B
5
S
1
Posts: 4
Reputation: 415


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, blissfulwizard, Malhog and 14 guests