![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Macryc |
Hi Guys. I’m testing a point-and-click movement mechanics in 3D, which is working fine. I have a move_to
function which gets the path between the character’s current position and target. The target is assigned in the main script (basically casting a ray from the mouse and capturing the position where collides with the ground). I’m using the move_and_slide
method to move the character along the path towards its target position.
Question: how do I ease-in the movement so that the character doesn’t abruptly stop when it reaches the target position??
Here is the character script:
var path = []
var path_index = 0
var move_speed = 12
onready var nav = navigation node
func move_to(target_position):
path = nav.get_simple_path(global_transform.origin, target_position)
path_ind = 0
func _physics_process(delta):
if path_index < path.size():
var move_vec = (path[path_index] - global_transform.origin)
if move_vec.length() < 0.1:
path_index += 1
else:
move_and_slide(move_vec.normalized() * move_speed, Vector3(0, 1, 0))