0 Favourites

How do I Make the Crosshair slowly follow player

  • Hey guys i am trying to figure out how to make the crosshair slowly follow the player. I know if setting position to another object it would directly go to the player instantly and that's not what i want. Any assistance would be greatly appreciated.

  • Put pathfinding on the crosshair, and set the the speed to what you consider slow. Then you must make an event to find a path towards the player every tick, and make an event where once a path to the player has been found, it will move along that path. This way it will constantly follow the player in a natural way, and you can even give it obstacles it has to go around it you like.

  • I'm assuming your crosshair is just on top of the screen and likely wouldn't need to go around things (why would it?). You need to set its position over time. I'd, personally, use lerp for this.

    If --compare two values-- Distance(player.X,player.Y,crosshair.X,crosshair.Y) > 5,

    Then crosshair>set position> X: lerp(Self.X, player.X, 3*dt), Y: lerp(Self.Y, player.Y, 3*dt)

    Change the "3" to change the speed of the effect. The "5" up there is a small deadzone at your player's origin--technically not necessary.

    This manual entry will explain those system expressions a little more if you need it. The gist (for these purposes) is it will slowly move towards the player and decelerate as it arrives (side note: technically, it will never arrive, but you can just round it off when its close enough). You could use fancier ways to get it to move, but this is a simple way to give a constant, smooth motion towards a target.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • C-7 PrimalNews got it working thank you very much!

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