0 votes

I'm making an Among Us clone, and I have it to where you can join the server and it shows the kill button if you're the Imposter, but I need help making the functionality.

The game is a 2d Top-Down server-client game.

I really need to check if the closest player is less than __ away and if the cool-down is = 0, and then if so, send an rpc_id function of KILL or something to that client, but I don't know how to do that.

Thanks in advance!

Godot version Godot Engine 3.3.3 (Steam)
in Engine by (87 points)

1 Answer

+1 vote

Setting up an rpc loop is a complex topic, I couldn't hope to begin cover it in a single text comment.

I recommend you watch this excellent series by Stefan at the Game Development Center YT channel which walks you through the whole process and discusses the pitfalls: https://youtu.be/lnFN6YabFKg

by (499 points)

Thanks, but I was really trying to keep away from that. It's really advanced, and I was really wondering how to tell the distance between players

Well yes, online multiplayer is advanced... That's like saying you want to design a microchip but you don't want it to be complicated.

At it's most basic I suppose you can make a dict containing the player id and Transform and each player can send their position to the server. Then server side you loop through the players and return an array with the other players and their Transforms. Then client side you loop through it, get your distances and pick the closest one.

Thanks, I'll try that.

When I started this, I never thought it would be easy, but I guess I never thought it would be this complex.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.