Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using BeardedManStudios.Forge.Networking.Generated;
  5. using BeardedManStudios.Forge.Networking;
  6.  
  7. public class CubeNetworking : CubeNetworkingBehavior
  8. {
  9. private void Start()
  10. {
  11.  
  12. }
  13. private void Update()
  14. {
  15. if(!networkObject.IsOwner)
  16. {
  17. transform.position = networkObject.Position;
  18. transform.eulerAngles = networkObject.Rotation;
  19. return;
  20. }
  21.  
  22. transform.position += new Vector3(
  23. Input.GetAxis("Horizontal"),
  24. Input.GetAxis("Vertical"),
  25. 0)*Time.deltaTime*5;
  26. transform.eulerAngles += new Vector3(
  27. Input.GetAxis("Horizontal"),
  28. Input.GetAxis("Vertical"),
  29. 0) * Time.deltaTime;
  30. networkObject.Position = transform.position;
  31. networkObject.Rotation = transform.eulerAngles;
  32.  
  33. if(Input.GetKeyDown(KeyCode.Space))
  34. {
  35. networkObject.SendRpcUnreliable(RPC_MOVE_UP, Receivers.AllProximity);
  36. networkObject.Networker.ProximityDistance = 50.0f;
  37. }
  38.  
  39. }
  40.  
  41. public override void MoveUp(RpcArgs args)
  42. {
  43. transform.position += Vector3.up;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement