Creating a Distance Counter [SOLVED WITH SYSTEM EXPRESSIONS]

This forum is currently in read-only mode.
From the Asset Store
Awardkit
$3.50 USD
30% off
Create custom awards and achievement or use the many templates and create your own.
  • This is something I assume to be fairly simple:

    I would like to set up a counter on my HUD for my game that tells the player how far away, in X-coordinates, he or she is from the level-end checkpoint.

    So for example, if the player is 3000 pixels away from the checkpoint, the counter will say 3000. And if the player moves 20 pixels to the left, the counter will say 2980. And if the player moves 20 to the right, it will say 3020, and so on and so on.

    This particular level I'm making is going from right to left, so I don't know if that would change anything.

    The way I've tried to go about this is giving the checkpoint a variable "Distance", and setting it to Checkpoint.X - Player.X , and setting the HUD Text to that, but that only gives a static number, which confused me.

    I have a feeling that it has something to do with the System action Compare Values, but I am pretty unversed in actions regarding those.

  • Well you could use system expression "Distance between points"

    Even though it's not X then only but shouldnt matter for platformer game that much or?

    http://dl.dropbox.com/u/904641/distance.PNG

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set your hud counter text to round(distance(player.x, player.y, goal.x, player.y))

    Assuming you only want to measure straight along the X axis and not a vector along XY.

  • Ah, thank you, that is exactly what I was looking for!

    Both methods work just dandy- after that it's a matter of preference, I suppose.

    Thank you both for the help. System expressions are some of the things i know least about in Construct, and more often than not, they contain the answers to my problems.

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