How do I limit crosshair movement while using gamepad controls?

0 favourites
  • 2 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hey guys

    I'm making a top-down shooter with gamepad controls - left stick controls the player while right controls the crosshair. I'm using 8-directional movement for both player and crosshair.

    Currently I've managed to use simple formula where crosshair moves freely around the screen but when released it get's back to player's position

    Every tick -> cursor: set position to (lerp(Self.X, player.X, 0.025), lerp(Self.Y, player.Y, 0.025))

    I'm looking for a method to constrain crosshair's movement to specific distance from and to the player so it can fly away to maximum eg. 100px but also cannot be closer than eg. 30px.

    Something like in this image

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Im not sure if this is exactly what you're looking for but it may help.

    (Instead of -100 and 100, use the size of the bounds that you want to keep the cursor in)

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