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"

How can I use a Variable as Value inside of a timeline?

Hi, as you can see in the headline I am trying to set my Walkepeed with a timeline to slowly spow down. But I am using a Sprint funktion as well, so how can i use a variable in the timeline to slow down from the speed the pawn has at the time? Thanks. I apologize for my englisch.

Product Version: UE 4.21
Tags:
more ▼

asked Feb 19 '19 at 06:18 AM in Blueprint Scripting

avatar image

Klimpertod
9 2 1 3

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

1 answer: sort voted first

how can i use a variable in the timeline to slow down from the speed the pawn has at the time

You cannot (well, you can, but it's fiddly and awkward), and that's not what Timelines are used for. Their tracks are better used as alpha to interpolate between 2 set values.


In order to smoothly change player walking speed, it's much better to fInterpTo between 2 target values during tick - this will give you a smooth transition that can be interrupted (or reversed) much more elegantly than a timeline.

more ▼

answered Feb 19 '19 at 10:27 AM

avatar image

Everynone
13.8k 74 25 57

avatar image Klimpertod Feb 19 '19 at 11:34 AM

Ok, thanks. Helped me a lot.

avatar image Klimpertod Feb 23 '19 at 08:38 AM

Well, could you pls tell me, how the awkward way works? I tried it with the Finterp to, but i dont know how to break it, i used a while loop, but it said infinte loop.

avatar image Everynone Feb 23 '19 at 10:21 AM

While loop? Definitely not the right way to go. And do not pursue the timeline way, it's not worth your time in this case - timelines have a specific use where you need to interpolate in precisely X amount of time. In your case, as you observed yourself, the current player speed is quite a fluid value.

The most basic sprint system would look like this:

alt text

For as long as you hold shift the player speed is 1200, if not shift is pressed it goes back the 600. The fInterpTo will smoothly change it between the 2 values based on its Interp Speed (the higher, the faster the transition).


Not entirely sure what you're after but if you need 5 different players speeds, I would build an enumerator and plug it into the Select node above. This will give you access to different movement speeds that can be easily modified by something that lives outside the player BP (entering shallow / deep water, stepping on a speed tile and so on). And it does not need to revolve around a player holding a key, of course.

If what I posted is not enough and you can't get it to work the way you imagined, consider dropping a bit more of descriptive info regarding how you envisioned it! I'll try to chip in what I can.

And good luck!

edit: typos

capture.png (207.7 kB)
avatar image Everynone Feb 23 '19 at 11:28 AM

So for example:

alt text

And any other blueprint can do something along the lines:

alt text

Untested but should work. Hope it helps.

lb.png (64.3 kB)
avatar image Klimpertod Feb 23 '19 at 11:57 AM

Thanks, but actually i am trying to create some kind of slide like in titanfall 2. I had a second question for that and i solved it based on that, but at the time it doesnt matter, if i am running or walking so i want it to slow down based on the velocity the pawn has at the time.

avatar image Everynone Feb 23 '19 at 12:03 PM

Not particularly familiar with Titanfall 2 mechanics (apart from wall running) but it sounds like the method I suggested is perfect for this.

if i am running or walking so i want it to slow down based on the velocity the pawn has at the time.

Not following this bit at all. You want to slow down based on the current player speed? Surely, you want an external factor to modify your speed, right? I am confused, are you talking about time dilation or player movement speed - these are 2 completely different things!

avatar image Klimpertod Feb 23 '19 at 12:40 PM

Player Movement Speed First i am checking if the velocity is my crouch speed Then i do have a timeline, wich goes from 1400(200 more than runspeed) to 300(crouch speed) and i am setting the MaxWalkSpeed to that value and then add a forward movement input as long as i hold Left Ctrl. Everything works fine, but it does it with 1400 when i am running, walking or wall running(yes, i do have that, but inspired by a video).

avatar image Everynone Feb 23 '19 at 12:49 PM

Sorry, I don't understand what you mean. I don't even know at this point whether is works for you or still does not. Using a timeline for changing player speed is not a good idea, timelines are not dynamic enough. You have a working solution up there, take it or leave it. It will interpolate from any speed to any speed, any time, and smoothly, to boot.

Good luck.

(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