Пример #1
0
    // Client - tell client replications to play a gunshot particle effect
    public void OnShotBulletMessage(NetworkMessage _networkMessage)
    {
        ShotBulletMessage msg = _networkMessage.ReadMessage <ShotBulletMessage>();

        PlayerManager tempPlayer = NetworkHelper.GetObjectByNetIdValue <PlayerManager>((uint)msg.playerId, false);

        tempPlayer.OnShotTaken();
    }
Пример #2
0
    public void OnBulletSpawn(NetworkMessage _networkMessage)
    {
        // Read msg
        BulletSpawnMessage msg = _networkMessage.ReadMessage <BulletSpawnMessage>();

        // Create Bullet
        GameObject clone = Instantiate(this.bullet, msg.position, msg.rotation) as GameObject;

        clone.GetComponent <Bullet>().ownerId = msg.objectId;
        //NetworkServer.Spawn(clone);

        // Set velocity
        clone.GetComponent <Rigidbody>().velocity = clone.transform.forward * msg.speed;

        // Tell client player's to play a particle effect
        ShotBulletMessage newMsg = new ShotBulletMessage();

        newMsg.playerId = msg.objectId;
        NetworkServer.SendToAll(CustomMsgType.ShotBullet, newMsg);
    }