Player A shoots balls to Player B’s staffs
every staff have a point like 10
when the point gets to zero
the game object removes the authority for itself
in this condition the first ball from any side can get the game object’s authority
the problem is:
in the moment of authority removing the game object moving by itself without any code about transforms position
shooting bullets have rigidbody and are kinematic
other game objects have collider only
the bullet have collided before authority removal so many times but there is no any problem of moving
so I don’t think that there is any problem with physics
I suppose changing ownership also unflags the object as kinematic. At least that’s what Netcode for GameObjects does and the network frameworks are pretty much all alike.
I also notice you are simply removing client authority rather than instructing the server to change authority to the other player. I suppose this leaves the object server-controlled which is likely also simulating the physics for clients.
hello my friend
the game object we are removing the authority from is a simulation of a post tower
it doesn’t have rigidbody
only bullets have rigidbody
lets say the tower belongs to player A
player B shoots it
when the HP of tower became zero
it will lost the authority
the first bullet from any player will give the authority of that tower to that player
then it will have authority again
I build a new simple project like this:
void Update()
{
if (Input.GetMouseButtonUp(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out rayHit))
{
rayHit.transform.GetComponent<NetworkIdentity>().RemoveClientAuthority();
}
else
{
Vector3 Target = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f));
CmdPutTower(Target);
}
}
}
now
with simply clicking on screen if there is no any gameobjects there it will spawn one there
but if you click on a gameobject it will lose the authority
even with this implementation just in the moment of removing the authority (1- not even moments after that. 2-giving authority again is not a solution because it is already moved) the game object is randomly moving in client screen but in server it is in same place
I maid a SyncVar for game object position and give it value in the moment of spawning
then I checked the current position of game object in update function to correct it if needed
but the result was awful in the meddle of playing the game the tower running somewhere and come back again
I can change my game play to direct changing of authority if it is a solution
however it will be a bug for mirror
but I think the only method for changing authority is to removing it firstly and give it for other player
so it will happen again
You may want to look up some other threads about tennis, ping pong and similar racket based 1v1 games. There were a few recent discussions about it with potential solutions for Netcode for GameObjects eg changing ball authority whenever the ball gets hit or switches the side of the court.
I recommend to switch to NGO since hardly anyone seems to be using Mirror anymore based on user questions on here.
ok
I solved this by changing network transform sync direction to from server to client for all game objects
in this way game object in client view will controlled directly from server instance
and can not move by itself
and also I removed the part of script for controlling the movement of game object in client view