Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class ClientScript : NetworkBehaviour
- {
- public Application app { get { return GameObject.FindObjectOfType<Application>(); } }
- public UserModel userData;
- [SyncVar]
- public Vector3 myAngles;
- private Vector3 localAngles;
- public void Start()
- {
- myAngles = app.view.cameras.mainCamera.transform.eulerAngles;
- userData = gameObject.AddComponent<UserModel>();
- print("Hey hey");
- NetworkIdentity nID = gameObject.GetComponent(typeof(NetworkIdentity)) as NetworkIdentity;
- // Add some error checking here.
- userData.name = nID.isLocalPlayer ? "localPlayer" : "otherUser";
- userData.userId = nID.playerControllerId;
- userData.userName = "bubub";
- userData.userRole = nID.isServer ? UserRole.UserHost : UserRole.UserNormal;
- userData.userAvatar = "bubub1";
- userData.viewingAngle = new Vector3(0, 0, 0);
- if (isLocalPlayer)
- {
- app.model.users.user = userData;
- }
- app.model.users.userList.Add(userData);
- }
- public void Update()
- {
- if (isLocalPlayer)
- {
- CmdUpdateData(app.view.cameras.mainCamera.transform.localEulerAngles);
- }
- }
- [Command]
- public void CmdUpdateData(Vector3 angles)
- {
- // Update data on:
- // - Where each client is looking
- // - What commands each user inputs
- //
- myAngles = angles;
- userData.viewingAngle = angles;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement