CustomMovement does not go towards the object with Parallax

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hey

    Hard one

    Layer 1 have Paralax 100, Scale rate 100

    Layer 2 have Paralax 0, Scale rate 0 (movable on mobile - menu bar)

    Object is created on layer 1 and should go toward Obejct 2 (layer2)

    What's going on?, the screen moves on the mobile, and it needs the object to fall into the basket, which is on the movable layer 2.

    But system doesn't understand this and work only on static layer 1

  • If you create Object_A with coordinates 100, 100 on a layer with parallax 0, 0 the object will stay at 100, 100. If you move Object_B towards Object_A and B is at 5000, 5000, it will still move towards 100, 100 although Object_A is visible on the screen.

    To calculate the Parallax 100, 100 coordinates you must add the viewport to the coordinates of Object_A. But when the camera is moving you change the viewport too and Object_A will move away from Object_B until they reach the edge of the layout (provided 'Unbounded scrolling' is disabled).

    I dont know what exactly you want to achieve or how your game works, but I have the feeling that you have to rethink something.

  • You can also try this method:

    1. Convert object coordinates from layer 1 to layer 2

    Sprite set position to
    X: CanvasToLayerX("Layer 2",LayerToCanvasX("Layer 1", sprite.X, sprite.Y) ,LayerToCanvasY("Layer 1", sprite.X, sprite.Y))
    Y: CanvasToLayerY("Layer 2",LayerToCanvasX("Layer 1", sprite.X, sprite.Y) ,LayerToCanvasY("Layer 1", sprite.X, sprite.Y))

    2. Transfer object to layer 2 and then move it towards the basket, using Bullet or some other behavior:

    Sprite move to Layer "Layer 2"
    Sprite set Bullet enabled
    Sprite set Bullet angle of motion to angle(self.x, self.y, basket.x, basket.y)
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000

    Thanks Guys

    According to Dop:

    Yes it works!!!!

    I don't know what first part do but yes it;s work ;-)

    What I wanna to do?

    this is simple. Killed enemies leaves coins. And that coins moved to the wallet. Problem is that wallet is on layer with paralax 0, scale rate:0.(this is menu bar) So coins can't find wallet via CustomMovement.

  • I see now. So in this case the option with viewport could look like this:

  • I see now. So in this case the option with viewport could look like this:


    yeah its nice too ;-) thanks

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