How to make a sprite always stay in front of another[SOLVED]

This forum is currently in read-only mode.
From the Asset Store
Always Fashion
$16.15 USD
15% off
This Girls Game allows young fashionistas to develop their taste and skills as a fashion designer.
  • I'm making a game that uses mainly RTS Behaviour (although it's not a RTS game), and I need a small sprite to always stay in front of the main character. This sprite is kind of a targeting reticule, so it should always keep the same distance away from the character's sprite and always in it's front, even if the character turns around. I tried a lot of things, but they didn't work...

  • Just add an Always event that sets this object in front of the player object. Should work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The problem is how to make it stay in front. I only managed to make it stay close to the player, because when the player turns around, it doesn't turn together...

  • I think what you want is something like

    Always set Reticle position to:

    X: Player.X + cos(Player.Angle) * Desired distance from player

    Y: Player.Y + sin(Player.Angle) * Desired distance from player

  • Thanks a lot, Arcticus! It worked!

  • Or you could place it on a layer above.... as it is UI. I always have a UI layer.

  • I believe what he meant was, 'How do I make a sprite stay a certain distance from the player in the angle he's facing'

    The way its worded could easily be mistaken for, 'How do I make one sprite always appear on top of another'

    However in this case I would also recommend putting it in a UI layer above the game layer anyway so, for example, the aiming reticle doesn't get hidden by some wall you added later.

  • the formula doesnt seem to work when the player is being flipped with the mirror function

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