Hi there!
-
A Lerp, when used as I assume you tried it, will interpolate between the current position and the target position with a constant factor - this means, the object will get slower and slower, but mathematically never reach the target (it will come “infitesimaly close”). So that’s not the way to go here, unless you want this behaviour.
-
The simplest way to move an Actor as you describe would be something like this:
The vector (here with 1, 1, 1) holds the speed values, it will move in the direction with each tick. As long as the values are small, it’s fairly smooth
The problem with moving via event tick is that you dont have a constant framerate, making it hard to define a very specific movement speed. You’d have to take delta seconds into account
- (!) Keep in mind that an actor usually has a collision mesh/gravity and might collide with terrain or other stuff in your world. If you don’t want that, set the teleport bool, or disable collision entirely for your actor.
Also (!) Gravity might be enabled. Since you want to move in z direction (which is up), that might counteract your movement.
- With a timeline, this works:
with the according timeline (a vector with a constant value to be added to the location):
The Timeline vector are the simple constant speeds. Instead of calculating how long it should move, i’d check for the distance and stop when close enough. (like a slider on a rail triggered by a switch thats supposd to go somewhere) That would be something like this:
The branch stops the timeline movement when the actor has reached it’s target -
Sidenote, in case you don’t know: float comparisons are usually not flat 0, so we have to use the distance within a certain range. If you just check “Target position == my position”, that might never happen, as float 0.122 is not equal 0.121, but we consider it to be the same position.
- There are other ways - especially for characters, AI Controllers are the way to go.
I dont’ know if this is the best option, but it’s the directest one I came up with. Hope it helps!
Cheers