Unity Networking Collision with 100+ Objects and Authority for all Clients,Unity Networking with collisions on 100+ objects
Hey I will directly go to the problems I currently have 2. I am new to networking and i'm using MIRROR NETWORKING. This is a Networked Project with 20+ players, 1 Server.
1st Question: I have a sprite that is split into 100+ gameobjects(fragments) with rigidbody2D and colliders attached. This sprite should be able to be destroyed by every player. If one player is touching it with their COllider it should fall apart. These fragments are children of the original sprite object and should get enabled on collision with the parent sprite, they are disabled on default.
Problem: If I attach a Network Identity and send the collision object to the server with a Command and then do a RPC to destroy/move it on all clients, it should theoretically work. BUT the Network Identity is enabling ALL the children at once after joining the game screen which results in total lag and a logic break, as the fragments should only be enabled on collision. It works in singleplayer. CODE:
[Command]
void CmdOnCollision(GameObject collision)
{
RpcOnCollision(collision);
}
[ClientRpc]
void RpcOnCollision(GameObject collision)
{
if (collision.transform.tag == "fragment")
{
Destroy(collision.gameObject);
}
if (collision.transform.tag == "parent")
{
collision.transform.GetComponent<SplitSprite>().SplitUpAndEnableRigidbody();
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
CmdOnCollision(collision.gameObject);
}
2nd Question: In the Scene there is 1x FuelTank and 20 Players(Tanks) with Fuel. Every player should be able to activate the FuelTank, to refuel their tank. The tank is then getting more and more empty for all players.
Problem: If I acces the "ToggleFuelTank" function on the FuelTank, it says I dont have authority. But every player should have Auhtority in this case, how to achieve that?
Thanks in advance
Your answer
Follow this Question
Related Questions
How do I give authority over a gameObject that already exists 0 Answers
distinguish players for collision between them 0 Answers
Network Rigidbodies act weird? 0 Answers
Networking Transform Hacks?? 0 Answers
Network collision delay problem 0 Answers