devNotes 3-30-16 networking – Parenting netCamera – netCamMove code

 

net_connect

public class netCamMove : NetworkBehaviour
{
    bool bLMButtonisDown = false;
    bool bRMButtonisDown = false;
    bool bMMMouseButtonisDown = false;
    float xMouse_Damped;
    float yMouse_Damped;

    GameObject aCam;

    public override void OnStartLocalPlayer()
    {            
        aCam = GameObject.Find("Argos_Camera");
        aCam.transform.parent = this.transform;
        this.name = "ArgosNet_Local";
    }

    public override void OnStartClient()
    {
        if (!isLocalPlayer)
        {
            this.name = "ArgosNet_Remote";
        }
    }

    void checkMouseButts()
    {
        if(Input.GetMouseButtonDown(0))
        {
            bLMButtonisDown = true;
        }
        if(Input.GetMouseButtonUp(0))
        {
            bLMButtonisDown = false;
        }
        if (Input.GetMouseButtonDown(1))
        {
            bRMButtonisDown = true;
        }
        if (Input.GetMouseButtonUp(1))
        {
            bRMButtonisDown = false;
        }
        if (Input.GetMouseButtonDown(2))
        {
            bMMMouseButtonisDown = true;
        }
        if (Input.GetMouseButtonUp(2))
        {
            bMMMouseButtonisDown = false;
        }
    }

    void Update()
    {
        if (!isLocalPlayer)
                return;

        float x = Input.GetAxis("Mouse X") * 60f * Time.deltaTime;
        float y = Input.GetAxis("Mouse Y") * 60f * Time.deltaTime;

        xMouse_Damped = Mathf.Lerp(xMouse_Damped, x, 0.1f);
        yMouse_Damped = Mathf.Lerp(yMouse_Damped, y, 0.1f);

        checkMouseButts();
        if (bLMButtonisDown)
        {
            transform.Rotate(-yMouse_Damped, xMouse_Damped, 0);
        }
        if(bRMButtonisDown)
        {
            transform.Translate(xMouse_Damped / 10f, yMouse_Damped / 10f, 0);
        }
        if (bMMMouseButtonisDown)
        {
            transform.Translate(xMouse_Damped/10f, 0, yMouse_Damped/10f);
        }
    }
}

 

network

TODO Next:

Send Button Messages across network.

Paint, Quad, Hex, Spawn, – Identify with alternate textures

Limit spawn to predictable – or think of a transport for the random generated path.

Paint – alternate Object Shader and Paint trail