Collision on layers with different parallax?

0 favourites
  • 5 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • 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...

  • 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.

  • 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 ..

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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