Most efficient way of moving an actor Tick() or Timer or Timeline?

I have an AActor and I’d like to move it:

  1. From one point to another point in the world (both points are FVectors)
  2. 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?

Note: I’m trying to achieve this in c++

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”

1 Like

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.

1 Like

i don’t think you can easily use timelines in cpp.

timelines would have an overhead in management. but probably not much, or the same overhead you might introduce.

i’d say that efficiency is not an important category to choose from these two options.

i find timelines extremely disruptive to regular programming so i find ticking much better.

i usually use ticks or timers. they are really great options.

with ticks you can put it in a component and do many interesting things:

  • time dilation
  • pause the game
  • control ticking interval depending on different things (eg on camera distance).

i’ve made a free open source plugin that uses components and ticks to animate all sort of things. materials, transforms, mpcs, sounds, etc etc.

you can always store a spline, and get the point across the spline based on a percentage, and set that. and it wont be much slower than a timeline.

here’s the base class. is quite complex because i keep adding stuff. but you can take it as inspiration and make something simpler.

here’s the one that animates the transform.

i don’t think that’s accurate. you can change the tick interval freely. i use it to add a special effect on my game.

1 Like

I was considering ticking inside a UObject instead of a component, These features will still work in it right?

Also nice plugin I’ll definitely look deeper into it for reference

1 Like

yup. time dilation and pause are controlled by unreal. you just get a call to Tick with the corresponding delta time.

there’s also a variable that controls whether a component ticks during paus. i think is “tickwhilepaused” or smth. Set Tickable when Paused | Unreal Engine 5.6 Documentation | Epic Developer Community (beware it has a few caveats undocumented. for example it won’t work if the tick interval is >0)

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.

thanks i hope it helps you.