[SOLVED] How do I move my crosshair along with the player?

0 favourites
  • 9 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello,

    I am making a top-down shooter, played with a gamepad. I currently move with the left stick and move the crosshair with the right stick.

    What I want to do now is to move the crosshair with the player when I don't move the right stick. It's a common feature in that kind of game. You can see what I mean in this Hotline Miami for PS Vita video :

    Subscribe to Construct videos now

    How can I do that? Is it possible to get the variation of the player's position instead of its position?

    I can't upload a capx right now as I'm at work but I can do it tonight if that helps.

    Thanks !

  • all you you is add crosshair with the right stick in with player movements

  • Yes, add the player movement to the crosshair so it can move along with the player. That's basically what I'm asking: how to do it. :p

  • Flodcp try this remember there are many ways you could do it. This is simple

  • Thanks for your help, unfortunately it doesn't work for me.

    I can get if the right stick is moving or not (I tested with a boolean and it works).

    I write that when the right stick is moving, then the crosshair position is the right stick one (it works).

    I then create another event where I write that when it is not moving, it should be pinned to the player. And it doesn't work.

    I will upload my capx this evening.

  • As you wish we will look at it and see if we can help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I joined the capx to this message.

    The disabled "move to position(200,200)" works, that's why I don't understand why the pin doesn't.

    Thanks again for your help.

  • Add two instance variables to your crosshair : offsetXPlayer1 and offsetYPlayer1 which will both be what you call the "variation".

    Add a start of layout event in which you set the offset for each axis.

    When the right stick is moving, modify the offset accordingly too.

    When the right stick is not moving, position the crosshair to be at the position of the player + the offset.

  • Thanks a lot Kyatric! Your solution worked perfectly.

    Love this helpful community.

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