예제 #1
0
    private void OnSpawnBullet(Net_SpawnBullet msg)
    {
        //Debug.Log("BulletSpawn Message Recieved");

        Vector3 pos = new Vector3(msg.x, msg.y, msg.z);
        Vector3 dir = new Vector3(msg.xDir, 0f, msg.zDir);

        GameObject g = Instantiate(FindObjectOfType <PlayerController>().bulletPrefab, pos, Quaternion.identity);

        g.transform.forward = dir;
        g.GetComponent <BulletController>().myID = msg.bulletID;
        Destroy(g.GetComponent <Collider>());

        bullets.Add(msg.bulletID, g);
    }
예제 #2
0
    private void OnSpawnBullet(Net_SpawnBullet msg)
    {
        //Spawn Bullets in server scene
        Vector3    pos    = new Vector3(msg.x, msg.y, msg.z);
        Vector3    dir    = new Vector3(msg.xDir, 0f, msg.zDir);
        GameObject bullet = Resources.Load("Bullet") as GameObject;
        GameObject g      = Instantiate(bullet, pos, Quaternion.identity);

        g.transform.forward = dir;
        g.GetComponent <BulletController>().myID = bulletID;
        msg.bulletID = bulletID;
        bulletID++;

        bullets.Add(g.GetComponent <BulletController>());

        Send(msg, clients);
    }
예제 #3
0
    public void OnBulletSpawn(GameObject bullet)
    {
        Vector3 vec = bullet.transform.position;
        Vector3 dir = bullet.transform.forward;
        //Send over spawn position and direction
        Net_SpawnBullet msg = new Net_SpawnBullet
        {
            ownerID = ourClientID,
            x       = vec.x,
            y       = vec.y,
            z       = vec.z,
            xDir    = dir.x,
            zDir    = dir.z
        };

        //Debug.Log("BulletSpawn Message Sent");
        SendServer(msg);
    }