How to make a simple 2D carry / mount system?

Godot Version

Godot Engine v4.2.2


How do I implement a simple 2D carry system between two playable characters? This for a platformer where you control a character and their mount, think Mario and Yoshi in Super Mario World.

This is a screenshot of the horse character, the idea is that the knight jumps to their head to mount it:


  • Area2D recognizes them entering (using the signal body_entered?),
  • Sets knight character to a suspended / idle state,
  • Anchors knight to the mount position (position.x = mount.position.x-50) (same for position.y)
  • Activates the control of the mount for them to react to the player’s inputs.

Is this the right way? Is there an easier method? Should the mount also be CharacterBody? Usually I ask when I have some code failing, but in this case haven’t found any examples to follow, so I’m not sure where to start.

Alright, I made the first version of the system and seems to recognize the Knight at least. But doesn’t seem to swap the variable for which one is active.

func _on_mount_area_2d_body_entered(body):
	var overlapping_objects = $ActArea2D.get_overlapping_areas()
	for area in overlapping_objects:
		var parent = area.get_parent()
		if parent == player_1_knight: == 2
			while swap_active == 2:
				player_1_knight.position.x = player_2_horse.position.x - 25
				player_1_knight.position.y = player_2_horse.position.y - 25

The way I connected the two character is through an autoload script. That’s where the Active variable is present. Is that the correct way to do it, or is there a better way?

Here’s the autoload script

extends Node

@onready var active = 1
@onready var player_1_knight = $Player1Knight
@onready var player_2_horse = $PLayer2Horse

Here’s in the character script.

#Autoload to manage characters
@onready var swap_active = get_node("/root/PlayerVariables")
@onready var player_2_horse = $PLayer2Horse
@onready var player_1_knight = $Player1Knight