Move an object to another object?

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

    I want the player to collect coins and on collision with coin I want the coin to move to the "Coin-counter-sprite" like I have seen in lots of games. I have tried do achieve this with the bullet behavior and all the other behaviors as well but with no success. Is it possible to do this in Construct 2?

    I also want to achieve a magnet effect where the coins move to the player if the player collects a magnet.

    If you don't understand what I mean then this video shows exactly what I want. It's Temple Run

    Subscribe to Construct videos now

    Thanks in advance,

    Tommy /

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What's wrong with Bullet behavior? Disable "Set angle" in Bullet properties, set angle of motion to angle(coin.x, coin.y, destination.x, destination.y) and it should work.

    If you want a nicer looking movement with acceleration/deceleration, I recommend LiteTween or MoveTo addons:

  • Thank you for your reply but I have already tried that though. The problem with that solution is if the player is still running then the coin will end up where the Coin-Counter-Sprite were when player first collided with the coin. The Coin-Counter-Sprite is always on screen so if the player move right then so do the Coin-Counter-Sprite.

  • Is the Coin-Counter-Sprite located on a separate layer with 0 parallax?

    You will need to move the coin to that layer (using "Move to layer" action), adjust its position and then enable Bullet.

    Converting coordinates between layers with different parallax is a bit complicated.

    Say, if you need to move the coin from layer "Main" to layer "HUD":

    Set newX=CanvasToLayerX("HUD", LayerToCanvasX("Main", Coin.X, Coin.Y), LayerToCanvasY("Main", Coin.X, Coin.Y))

    Set newY=CanvasToLayerY("HUD", LayerToCanvasX("Main", Coin.X, Coin.Y), LayerToCanvasY("Main", Coin.X, Coin.Y))

    Coin move to layer "HUD"

    Coin set position to (newX, newY)

  • Hey Dop! You always have great solutions but as always, they don't work for me at first because I don't completely understand them :p

    Can you see what I have done wrong here?

  • You forgot to move the coin to BG layer. And this will only work if your Coin and CoinCount are on layers with different parallax setting.

  • You are without a shred of doubt the most awesome person on this forum, if not the whole universe!!! Your solution is perfect, as always! A thousand thanks

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