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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Link to timelines doc for c++?

Hello everyone! I am just now diving into C++ from blueprints, and I use timelines a lot in blueprints and was wondering if they were in C++, and if so is there a doc I could use?

Product Version: UE 4.10
Tags:
more ▼

asked Mar 03 '16 at 07:13 PM in C++ Programming

avatar image

Designer102
86 18 19 26

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

2 answers: sort voted first

After trying this before I thought I give this timeline in c++ another shot. There are still some old answers here on answerhub which show how to use timelines in c++ with the actor's own tick function. But actually it also works withouth using the tick of the actor. I had to use AddInterpFloat() at runtime to get this to run.

This answer should work for you!

//.h

 UPROPERTY()
 UTimelineComponent* ScoreTimeline;

 UPROPERTY()
 UCurveFloat* fCurve;

 FOnTimelineFloat InterpFunction{};
 

//.cpp

//Constructor:

 static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy(TEXT("CurveFloat'/Game/Blueprints/NotSoImportant/CurveFloatBP.CurveFloatBP'"));
 if (Curvy.Object) {
     fCurve = Curvy.Object;
 }

 ScoreTimeline = ObjectInitializer.CreateDefaultSubobject<UTimelineComponent>(this, TEXT("TimelineScore"));

 InterpFunction.BindUFunction(this, FName{ TEXT("TimelineFloatReturn") });


//Then inside BeginPlay for example:

 ScoreTimeline->AddInterpFloat(fCurve, InterpFunction, FName{ TEXT("Floaty") });
 ScoreTimeline->Play(); // or PlayFromStart() etc, can be called anywhere in this class

//And Finally your callback function:

 void AYourClass::TimelineFloatReturn(float val)
 {
  //Your float val from curve returns here
 }

}

I made a wiki page about this here:

https://wiki.unrealengine.com/Timeline_in_c%2B%2B#How_to_use_Timeline_in_c.2B.2B

more ▼

answered Apr 05 '16 at 09:33 PM

avatar image

spaceharry
392 21 30 138

avatar image Torfi Apr 11 '16 at 02:42 PM

I had to add UFUNCTION to the declaration of the "TimelineFloatReturn" function but otherwise this seems to work perfectly, thanks!

avatar image TheLoneStar Jul 18 '16 at 06:03 AM

Hey @spaceharry, how would create your own curve in this, but where do you add value for it?

avatar image TheLoneStar Jul 18 '16 at 05:09 AM

Hey @spaceharry, how would create your own curve in this, but where do you add value for it?

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

Hey Designer102-

You'll want to look into using timers in code. The class for timers is Runtime/Engine/Public/TimerManager.h and there is a short tutorial on setting up an actor that uses a timer:

https://docs.unrealengine.com/latest/INT/Programming/Tutorials/VariablesTimersEvents/1/index.html

Let me know if this info helps.

Cheers

Doug Wilson

more ▼

answered Mar 03 '16 at 07:57 PM

avatar image Designer102 Mar 03 '16 at 08:46 PM

The timer wont work for what I am trying to do, have a variable change overtime once a function is called, I am thinking of using a curve asset, is there a doc for that or any tips and tricks?

avatar image Doug E ♦♦ STAFF Mar 03 '16 at 09:30 PM

Unfortunately using a timeline in blueprints does not translate to code cleanly. If you are trying to change the value of a variable based on time then your best bet would be to use a time or to edit the variable in the Tick function so it will update with each tick.

avatar image spaceharry Apr 07 '16 at 09:08 AM

U actually can use Timeline c++ in the same way as in blueprint withouth using a boolean or tick of the actor where the timeline is in. See my answer below.

avatar image Designer102 Mar 03 '16 at 11:52 PM

I was actually planning to make it so a boolean is set to true in a function, then in the tick it will check for if the boolean is true and if so it will add to a float and if the float is over or at my wanted amount it will set the boolean to false, would that work?

avatar image Doug E ♦♦ STAFF Mar 04 '16 at 03:16 PM

That would work. Just keep in mind that while the bool is true, the float will increase every tick.

(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