First it is necessary that you share more information about what/how you want to do something. From your description no one here will be able to help you. Don't forget to mention what you already tried and how your data looks like.
Anyway for that to work its crucial to have access to the current players coordinates. If you have them you can try something like the following PSEUDO code:
Code:
# variables
recorded_route = [(x1, y1), (x2, y2), (x3, y3), ...] # List of recorded coordinates
current_coord_index = 0 # Index to keep track of the current coordinate in the route
# Function to get character's current position
function get_character_position():
# like mentioned get the coordinates here either by accessing the characters object or directly read it out from the recv function
return character_instance.position # Return character's position (x, y)
# Function to move character towards a target coordinate
function move_character_towards(target_x, target_y):
current_x, current_y = get_character_position() # Get current position
# Calculate the direction vector towards the target
direction_x = target_x - current_x
direction_y = target_y - current_y
# Normalize the direction vector (optional but recommended to control speed)
direction_length = sqrt(direction_x^2 + direction_y^2)
normalized_direction_x = direction_x / direction_length
normalized_direction_y = direction_y / direction_length
# Set the character's movement (you might have a function for this in your code)
set_character_movement(normalized_direction_x, normalized_direction_y)
# Function to check if character reached the target coordinate
function has_character_reached(target_x, target_y):
current_x, current_y = get_character_position() # Get current position
distance_to_target = distance(current_x, current_y, target_x, target_y)
return distance_to_target < tolerance_threshold # Check if character is close enough to the target
# Main function for running along the recorded route
function run_along_recorded_route():
while current_coord_index < len(recorded_route):
target_x, target_y = recorded_route[current_coord_index] # Get the current target coordinate
move_character_towards(target_x, target_y) # Move character towards the target coordinate
# Wait until the character reaches the target coordinate
while not has_character_reached(target_x, target_y):
wait_for_short_interval() # Add a small delay to control the movement speed
# Character reached the target coordinate, move to the next one
current_coord_index += 1
# Character has reached the end of the route
set_character_movement(0, 0) # Stop character's movement
# call main function
run_along_recorded_route()