This may be difficult to explain so bear with me.
I’ve set up a Unity online multiplayer game (it’s in it’s first stages right now), using UNet, where you can connect with each other, see each other move and rotate, kill each other and such.
The problem I’m having is with the Particle Systems for the guns.
I’ve set it up so that it detects whether or not you hit a player by raycast, so the particle system I added is just for looks, but I cannot get it to sync correctly over the players.
I’ve got it to the point where the particle system appears for the other client on the server, so they see it spawn, and the bullet move for a short while, but then the bullet disappears on the non-local players screen, but it continues to move on the local players screen.
I’ve tested around with this a lot, it’s very weird, because when I turn down the speed of the particle system, when the particle system spawns on the server again, the particle system appears again, but travels a certain distance, and then disappears. Whatever the speed, it will always disappear after a certain distance for the non-local player.
What’s weirder is that the particle still definitely exists for the non-local player, since it’s still in the hierarchy, and also the fact that when the particle collides with the floor, even if the particle has reached the ‘invisible’ stage, the collision particles will still appear for the non-local player.
The setup I’ve got is that the particle system for the bullet is a Prefab (along with the collision particle system), and onto the bullet particle system, I have a network identity, and a network transform, and a network transform child (for the collision particle system).
I’ve got it on sync transform, and sync XYZ. I’ve played around with all the settings in the network transform’s and it makes no difference.
Here’s the basic setup of the script part for the bullet spawing:
@Command
function CmdShootParticles() {
var particleShoot = Instantiate(shootParticles, shootPoint.position, shootPoint.rotation);
Destroy(particleShoot, 5.0);
NetworkServer.Spawn(particleShoot);
}
function Update () {
if (!isLocalPlayer) {
return;
}
if (Input.GetButtonDown("Fire1")) {
CmdShootParticles();
}
}