Hi,
This is a bit of a hard problem to explain, but I figured out what is wrong with my game. So I have a networked game using UNET. The game is a flying spaceship shooter game. When the players shoots, a glowing particle blob gets fired from the front of the vehicle and if it hits an enemy craft will impose damage to the enemy. The particle gets created in front of the vehicle and has a speed that travels faster than the players craft, so the player that shot the energy ball won’t hit it’s own bullet.
The players craft has local authority - every player will send their transform via using network transform component to the server and the server will accept the client position of the player and update the servers copy of the transform. The energy ball that gets fired is owned by the server because i want the server to do all collision checks and damage checks. The client that shot the bullet doesn’t have the right to control the x,y,z location of the energy ball - the server will do this and run physics and send the coordinates back to the clients. the clients do however run client side prediction, but the bullet will get overridden to the servers copy as updates come in.
There is a problem with this design. When the client fires, he will call a command to the server which signals to start firing (When the craft is firing, the craft every half a second will keep firing a new energy ball). When the player wants to stop firing, there is a command to the server to stop this. So the client can’t hack sending thousands of bullets every second - They can only signal the server when they want to start firing and the server will work out the time between the bullets when to fire telling all clients about the new object and updating the clients with the x,y,z coordinates of the bullet.
The bullet has a character controller on it and a script which propels the bullet forward using the controllers move function. Here’s the problem, when the server creates the bullet, it looks at the current craft x,y,z position (Which remember is delayed because the client may have not sent the newer coordinates yet) and it creates the bullet in front of the vehicle. What happens next is the client then sends a transform update which will “Clobber” over the bullet (Since when the bullet was created on the server, at that time on the client the craft was slightly a little forward more) . Because there is a collision from this, the bullet changes direction to suit the collision and the bullet flies in a different direction that is not where the craft is looking at.
So, some solutions to this may be to see if it is possible to make the character controller not “Have” collisions with certain objects in the scene like the craft it is being fired from… Is this possible? If I put a trigger on the bullet and make the bullet move by updating the transform position, the trigger doesn’t notify when it hits a collider because triggers only notify when colliders move into it.
See the great thing about a trigger is that it notifys a collision but doesn’t block a collision, BUT it only works if things crash into it, not the other way around.
The other way is to use maybe a Physics.Raycast before every move and not have a character controller attached and update it’s x,y,z transform coordinate instead of using character controllers move method.