x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Adding a distance traveled and a distance to go to my Endless Runner

Hi all,

I am fairly new to UE4 and have a basic prototype for an endless runner. I can collect coins, have different power-ups and increase the total points as I run further.

I have a print string telling me the distance traveled but I need a distance to go. This is because I want to add a boss fights to my game which are unlocked when you pass a certain distance.

I want it to look something like this!alt text

I want the right value to change when you reach the distance. For example boss 1 will be at 100 meters and then boss fight 2 will be at 500 meters and so on. When you reach a boss fight the game will pause and the boss fight will commence a bit like Jetpack Joyrides SAM bot. I have the distances in a save file but i need help getting those numbers out of the array.

Another photo of the Save file with the values alt text

I hope someone can other some advice.

Thanks in advance Gadget

P.S Sorry its long

Product Version: UE 4.21
Tags:
screenshot-67.png (158.8 kB)
screenshot-69.png (170.8 kB)
more ▼

asked Mar 27 '19 at 11:21 PM in Blueprint Scripting

avatar image

GadgetGuy100
3 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Just use a simple "Get" node on your array, when the player reaches the target distance "get" index 0. But use a variable for the getter this way at each "boss" distance you can increment the getter so that it will give you the next distance once you pass the first one. For example name a variable "Boss Index" make it an integer type. Then start the value at 0, plug it into the array of distances. This will return index 0, which should be your closest distance say 100m. Then when the player reaches this distance, spawn the boss and increment "boss index" to now be 0+1. Once the player finishes the first boss, the distance you "get" from the array will be index 1, so that will be 500m. etc etc

more ▼

answered Mar 28 '19 at 02:20 AM

avatar image

Nebula Games Inc
5.4k 28 9 14

avatar image GadgetGuy100 Apr 06 '19 at 10:16 AM

Thank you for your response! I tried what you said and it solved my problem. Thank you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question