How do I create a Time & Distance tracker (for the player)?

Hi all,

I am very new to UE4 and it’s visual scripting software but have been able to recreate the Endless Runner tutorial over on the UE4 YouTube page. My goal is to make a prototype game (very basic) of an Endless Running game that is 1st person and focuses on parkour movements with PCG tiles and obstacles…

What I am trying to work out and create is a Time & Distance tracking which the player could see in the UI.The best example I can find of this being done is here: eFPS - Demo Project - Extensive Gameplay Reel - YouTube

If anyone could help I’d be very grateful, thanks!

Use Timer for time

If for distance, i assume you moving terren instead of character (never seeh tutorial so i’m not sure how they did infinit ranner game), you will need to cheat a little. Add up delta time on Tick event (in float varable, so on every tick you got increasing number) now you need sync the speed with scaleing delta time (multiplaying delta time you gonna add), this way you add up distance based of time with inclusion of speed. If character teleports than you simply add the static distance to varbale

Hi Shadowriver,

Thank you for the help. The link you sent are the ones I found previous to posting my question, so re-reading them and trying to make sense of them in a different context outside of the template referenced isn’t going to work (for me), but will try and again now.

As for the distance tracking, the world is consistently generated (PCG) while the player is forcefully being moved at a constant speed - just like a standard endless runner game. Would you be able to show visually the method you are explaining, I am struggling to understand it?

GOOD NEWS, I figured out how to do the timer. Now, I am just in need of help in creating the distance counter. Thank you.

Ok, then add up position difference between the ticks.

To get distance vector, you substract vector to vector, keep old position in varable and substract with new position and then use this node:

to get length of distance vector and you add up this on every frame creating distance counter. Keep in mind this gonna be very precise that smallest change in location number will be added up. You can also set Z to 0 in calculated distance vector to ignore Z axis if you like.

I’m going to be straight up honest with you right now, what you just said has confused me even more. If it is possible, could you illustrate what you just said with the Blueprint system? It’s very hard for me to understand what you explaining, I am very sorry about this.

ehhh, but i hope you will understand what this circuit will do

So you want time based or distance base? Decide. You can reduce increasement in very simple way you just need to move your head a little… divide float from VectorLenght thats adds up.

Thank you for this, it makes perfect sense now. My only problem is that the distance numbers are incredibly fast in rising. Is there a way I can set these independently for every second? So every second = 10 distance etc, because right now I am getting 1000.000 every second…

I didn’t realise there was difference between the two until right now, I apologise for that. I believe what I am after is the time based distance from the sounds of it.

I did try adding in a delay between the set distance and set last position, but that just speed it up. So I am trying to work it out. I’ve figured out that if I change the ‘distance’ variable from float to integer to get the figures to be whole numbers, so thats half the battle lol. I’ll try the divide float now and see what happens. I really do appreciate the help by the way :slight_smile:

Just shrink number that adds up (between VectorLenght node and + node), it’s common sence :stuck_out_tongue: best is if you divide output of VectorLength, by then 10 or 100, the more digits in divide the less digits in distance are added. If you don’t know divide in programing is represented by “/” symbol, you should find it near “+” node

I do know the symbols thankfully, it’s just using the right ones for the right thing :confused: You’d think it is, but that’s only common sense when you have coder logic, which I haven’t quite grasped fully yet hahaha, but using divide has done the trick! Thank you again for all the help Shadowriver! it’s got it working! :smiley: