How do I move a sprite relatively to another moving sprite

0 favourites
  • 9 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Hi guys,

    In the game I'm trying to make (top down view), my characters can move in a grid made of 32 * 32 cells. This is usually working fine apart from a little bug.

    At the moment, they can move in a spaceship, like in Faster Than Light basically.

    If the ship moves, let's say by 96px to the right, and a character is also moving to the bottom, the character ends up out of the ship. I'd like the character to move relatively to the position of the ship.

    How would you do that? Do you think you can achieve this with the pin behaviour?

    Thanks,

    EDIT: I Forgot to mention that I was using the MoveTo plugin if that makes any difference

  • pin behaviour should work fine

  • But, wouldn't pin keep him from moving the object on the platform (ship)?

    As far as I understood, he wants the avatar to inherit the vertical and horizontal speeds of the platform, so it doesn't fall behind it, while allowing him to move the avatar on the platform itself.

  • I'm not sure if that is what you are after, also I never used the MoveTo behaviour.

    But in case you want to move an object on top of another moving object, a key to make this work is to add the bototom object velocity to the top object velocity.

    Something like this:

    Top object overlaps bottom object at offset 0,5 (or -5, not sure)

    TopObject > set position > topObject.x + bottomObject.velocity.x, topObject.y + bottomObject.velocity.y

  • caiorosisca Actually, this wouldn't work. He must add together player velocity and platform velocity for both axis (horizontal and vertical) or else the player object would only move together with the platform object but wouldn't be able to move on it. In other words, this solution would work exactly as a position pin.

  • brunopalermo You are right, not sure what I was thinking when I wrote that out. What you need to do is to sum the bottomObject velocity to the topObject velocity and not set it's position. Thanks for pointing that ou

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made an example...

    You can check a preview here:

    http://examples.gamesintheattic.com/platforminertia/

    and get the .capx here:

    http://examples.gamesintheattic.com/platforminertia.capx

  • Awesome, thanks guys, I really appreciate it!

    brunopalermo Thanks a lot for making a capx, I'll test it when I get home. Don't have internet right now, so I'll reply tomorrow when I get back to work to let you know if I managed to integrate this to my little project

  • I have tested it and checked out the logic. I'm going to see how i can integrate it to my little project, but I think I'm going to struggle a bit! Thanks a lot for your help

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