Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. public class ClientScript : NetworkBehaviour
  7. {
  8. public Application app { get { return GameObject.FindObjectOfType<Application>(); } }
  9.  
  10.  
  11. public UserModel userData;
  12.  
  13. [SyncVar]
  14. public Vector3 myAngles;
  15.  
  16. private Vector3 localAngles;
  17.  
  18. public void Start()
  19. {
  20. myAngles = app.view.cameras.mainCamera.transform.eulerAngles;
  21. userData = gameObject.AddComponent<UserModel>();
  22. print("Hey hey");
  23. NetworkIdentity nID = gameObject.GetComponent(typeof(NetworkIdentity)) as NetworkIdentity;
  24. // Add some error checking here.
  25. userData.name = nID.isLocalPlayer ? "localPlayer" : "otherUser";
  26. userData.userId = nID.playerControllerId;
  27. userData.userName = "bubub";
  28. userData.userRole = nID.isServer ? UserRole.UserHost : UserRole.UserNormal;
  29. userData.userAvatar = "bubub1";
  30. userData.viewingAngle = new Vector3(0, 0, 0);
  31. if (isLocalPlayer)
  32. {
  33. app.model.users.user = userData;
  34. }
  35. app.model.users.userList.Add(userData);
  36. }
  37.  
  38. public void Update()
  39. {
  40. if (isLocalPlayer)
  41. {
  42. CmdUpdateData(app.view.cameras.mainCamera.transform.localEulerAngles);
  43. }
  44. }
  45.  
  46. [Command]
  47. public void CmdUpdateData(Vector3 angles)
  48. {
  49. // Update data on:
  50. // - Where each client is looking
  51. // - What commands each user inputs
  52. //
  53. myAngles = angles;
  54. userData.viewingAngle = angles;
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement