Jump to content
Miguel Preguisa

0.10 Editor Tutorial - Counting racetrack laps

Recommended Posts

I will join the competition this time :) Because, I have to say, the 0.10 exceeded my expectations. I never really understood the Editor. But with the new visual scripting, it feels more like a colorful LEGO :D

I tried to do a fully functionating race circuit. I've already had my modular Narrow Roads assets so now it needed some game logic!

And I may have failed to do so a little bit :P But I still did a lot of work and going through the Editor scripts so let me present my work.

5b8c0682e3452_2018-09-02(4).thumb.png.bf7d63f51a6fb262259996c2690e559d.png

What can it do?

  1. It counts your laps. There are three laps.
  2. It shows them to you.
  3. It's cheater-proof. You have to ride through both of the checkpoints in order to count the lap in.
  4. If you miss any of the checkpoints, it will tell you.
  5. It will also tell you when you finish the race.
  6. It can be played more than just once (reset after finish)

What it can't do?

  1. It doesn't count you your time :/ I spent the whole day trying to get it to work, but I didn't succeed. Any help or tutorial on Time Trigger will be appreciated!
  2. I wanted to let the player select the number of laps, but again, I didn't manage to teach myself to use the Ask Player or Dialogue game logic.

 

Demonstrative race. Look at the top right on the counting. And sorry for my terrible driving. Narrow Roads doesn't forgive a single mistake :D

 

Here's the demonstration of my checkpoints. Don't even try to bypass them. :P 

 

And how it's done?

I will start with the easy things moving to the harder ones.

  • Just a player role named Rider. Equipped with Tuxedo and Creator Cube - just in case.

2018-09-02.thumb.png.9dc244233df1aaf66eb2b1c6358d0c3a.png

  • UI panel for counting the laps. I think most of it is self-explanatory. I used Anchor to set the position of the text. Checked off Visible to new players so newly spawned players don't see lap counting even though they didn't start. Set the Background color to transparent by setting the Alpha to 00. The text "0/0" is for debugging, players shouldn't ever see this. It's changed by scripts in the last images. 

5b8c0c3ca41a3_2018-09-02(2).thumb.png.43e7ae4e91c5222daf4db299b8396538.png

  • Similar UI panel but for a message "Race finished!" when the player completes all three laps with all the checkpoints.

5b8c0c4325622_2018-09-02(3).thumb.png.ca96c51de4f1b341919441fb508cc8de.png

  • Now, moving to actual visual scripting, the checkpoints. There are two of them on the racetrack and they are made of Trigger Zones same as start/finish line.

5b8c0c567eeb4_2018-09-02(6).thumb.png.33335296bcc739c4e70d0e29296307bc.png

checkpoint.thumb.png.f95e6bc6ca361e59e93b4eb02f008825.png

  • Next one I should mention is the Global Storage. I used it to define the variables and transfer them to different game logic.
    • loop_count for counting the laps. Start with 0 because the player started 0 laps at the start.
    • reached_cp1 and reached_cp2 set to TRUE. These are the variables checking for the checkpoints. One for first, and one for the second. They are set to TRUE so the first time you pass the start/finish line, the game lets you start a new lap (the first one) without first going through both checkpoints.
    • total_time shouldn't be there :P I forgot to delete it after giving up on my dream of a fully functional racetrack.

5b8c0c372e79c_2018-09-02(1).thumb.png.6497808f4cec13d27140585fd898e937.png

  • Now the fun begins. This is the main thing I created.

The first image is without any further info.

5b8c0c4f86e18_2018-09-02(5).thumb.png.1ff8eadd4897096002fb3b6a39cad415.png

The second has the parts of code explained.

tutorial.thumb.png.c173fc7878bdabb2a5328ae6310459fc.png

And the third one is for those similar to me, who would get lost in the image above if they saw it for the first time xD

tutorial2_v2.thumb.png.5a02bc003b787ddc6a73c42cdb1bb931.png

Woah, that was more text than I thought I will write today xD

Hope you liked my tutorial and that you learned something new! I sure did when creating this. :) And shout out to @MyPa553ng3r who created the nice car I used when testing the race circuit. 

Edited by Miguel Preguisa
  • Like 3

Share this post


Link to post
Share on other sites

And just to clarify, I don't know how to code. This was probably the biggest thing I've ever coded and it isn't anyhow long. I managed to get this working just by going through different visual scripting components and without any tutorial. The new visual scripting feels very intuitive! 

Share this post


Link to post
Share on other sites

This is very well done.

To get a lap time, you could use a time trigger, set it to a very high time that won't run out.  When they finish the lap, there is a GET ELAPSED TIME command (Under Game Logics: Time Trigger) to find out how much time since the Time Trigger started.  Then you can either let it keep going for the next lap or reset it and get each lap time separately.  You could even let them know their time at each checkpoint.  I have not tried this, so I don't know how precise it would be, but it is a place to start.

 

Edited by Indomitus
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×