From one point to another point in the world (both points are FVectors)
Along a spline path
Now correct me if I’m wrong but my understanding is that if the point or spline is dynamically changing during the gameplay I should be using Tick
But what about when the point or spline is static and does not change (which is most cases) ?
In that situation which one is the most efficient way to move the AActor is it Ticking or Timer or Timeline? Or is there any other method I might not be familiar with?
which one is the most efficient way to move the AActor is it Ticking or Timer or Timeline?
Iirc timelines are not very c++ friendly, so i’ll skip this one. may be wrong though
Definitely don’t use timers for this. You should understand that they will run each tick required amount of times your “requested”. So if you set duration to 0.001, then for 0.033 second frame it will be run 33 times (in this example - 33 times at once every 0.033 seconds). Timers has it’s own goals and merits, but obviously - that isn’t the thing you looking for.
So, tick looks like a way to go. For example, even default CharacterMovementComponent is a basically Tick(){SetActorLocation(NewLocation);}(of course it’s greatly simplified example)
Now correct me if I’m wrong but my understanding is that if the point or spline is dynamically changing during the gameplay I should be using Tick
But what about when the point or spline is static and does not change (which is most cases) ?
You still have to change position of actor every frame. And you have to calculate new position every time you want to change it (unless you going to precalc all possible positions, but it doesn’t make sence for such precalc in context of dynamic framerate(deltatime)). So, type of spline (or any way of representation of path) doesn’t matter for chosing the correct way of “ticking”
I think it’s more a question of which is more appropriate. Unless you have a reason to max efficiency, it’s not enough to matter.
Tick will run every frame.
If you’re creating movement, and it doesn’t run every frame it will look choppy.
Timer is better for things that don’t need to run every frame.
Or if you have some reason to use it.
Timelines, I assume have more overhead than the others because they’re more complex. Useful in blueprint, not sure about C++. In blueprint this is the most common way I’d move along a spline. You have control of the curve and can run on demand. With Tick, you have to consider whether it should keep running…. does it run once, does it run indefinitely, is it evaluating code every tick even if not doing anything… That’s a downside of tick, you either leave code running or manage whether it should run or not yourself. Timers can be canceled. Timelines can run once or be canceled.
in order to control the tickinterval dynamically, that’s something you have to implement yourself.
the tickInterval functionality is there. but changing it is up to you.
i’ve also created this plugin for the Significance Manager that allows you to… basically change anything for any reason. but mostly is used to set “performance” on actor based on rules. out of the box i’ve implemented occlusion, distance, and visibility at least. it’s up to you what “performance” means, out of the box my plugin can de/activate components and or control their tick interval. is just plug and play. also it’s extensible through delegates and subclassing.
it implements a way to control the tick interval based on distances (and or visibility and or occlusion). you can either use the component itself or just get inspiration from it. in any case, using tick allows you to do this. you can’t do it with a timer nor a timeline.
Actually (and if I’m not mistaken), timers in Unreal Engine are registered with the FTimerManager, which updates them once per tick. Like most systems in the engine, timers are tied to the game’s frame rate, they’re checked and advanced every frame.
Timelines create an internal component (UTimelineComponent) that registers its own tick function. This tick runs each frame while the timeline is playing and automatically disables itself when playback stops.
The tick function (Tick()) is a method that any actor or component can register with the world’s tick system. It’s called every frame unless explicitly disabled. Setting a custom tick interval tells the world to accumulate delta time in a float and only execute the tick once that interval has elapsed, but it is still checked every frame.
sorry i was referring to the accuracy of the sentence not the tick.
what i tried to say is that a tick can run on every frame, but also run on a specified interval. if you choose to do so.
i agree with pezzott1 on what he says. though for me the important point is how it works for the user. timers are fixed when set to loopable, or you have to re-register them. and ticks can tweak their interval.
any of those 2 can notify every frame if desired, or at bigger intervals.