Rigidbody addForce on other Player

Hallo,
I’m looking for a workflow/Solution, to rigidbody.AddForce to other Players-GameObject-Rigidbody. Basically I do a SphereCast to get all near Colliders->Rigidbody, then calculate the direction and Rigidbody.AddForce to other Players-Rigidbody, but this way dont work on a Network.

I’m looking for a work around or somthing that could help.

Im using Photon Network.

If the force is an instant impulse then send either
1: Only apply force on server and all clients will automatically update their position/velocity next send
2: Send a vec3 to the client(s) with the force direction & magnitude.

If the force continuous then it becomes much more complicated. Either…
1: Calculate it client side
2: Periodically update the vec3’s direction and magnitude and sync the vec3

1 Like

take a look on NetworkTransport game example
but you will need to sync time or frames between clients and servers to survive with latency…

2 Likes

Thank you guys!Now I got a idea how I could do that.

Hey I know this is 2 years old, and they’re reworking Networking in Unity; but I just figured out the solution to this after literally a whole day of grinding through examples online and documentation. It’s so obvious now that I see it.

I was trying to go Client → ClientRpc, you have to make a stop at [Command] before you go to do the server function so that it’s the server making the request.

So go [Client] → [Command] → [ClientRpc]

PLAYER HITS THEM → TELL SERVER YOU HIT THEM → SERVER CHANGES OPPONENTS PLAYER

Can you explain it?

Another 2 years have passed and I need this now. Could you please elaborate on how to tell the server you hit them? I’m using mirror, the rebooted version of the original Unity networking. Thanks in advance :slight_smile: