Generate and register a new valid Multiplayer ID for adding bots?

Godot Version

4.2

Question

Hey, I was wondering if there was a way to register a valid Multiplayer ID that points back to the server, but is for a bot. Currently, I handle most things like so:

@rpc("any_peer", "call_remote", "reliable", 0)
func remote_apply_impulse(vel : Vector3):
	if is_local_authority():
		apply_impulse(vel, Vector3.ZERO)
	else:
		rpc_id(int(var_to_str(self.name)), "remote_apply_impulse", vel)

and

func is_local_authority():
	return $ClientMovement.get_multiplayer_authority() == multiplayer.get_unique_id()

This works great, but when I add bots, I encounter a problem. Bots are owned by the server, but need to also have their own ID. I’m wondering how I can

1.) Ensure that a bot I create has a valid ID and won’t conflict with another player’s multiplayer ID

2.) Find a way to cleanly target RPCs to affect bots that exist on the server. It can’t be “1” because “1” means the server and there isn’t information about what bot the target is. I don’t really want to edit every single RPC to include an extra integer that is only useful if the target happens to be a bot.

Thanks!

I issue fake negative PIDs to bots, and use them internally. The bots get spawned and synced on remote peers just fine, but I’m not using an authoritative server yet, so YMMV.

1 Like

You probably want MultiplayerPeer — Godot Engine (stable) documentation in English