Advertisement
Guest User

elf01

a guest
Jul 23rd, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class door : MonoBehaviour {
  5. public bool open;
  6. private float _timeout;
  7. public float Timeout;
  8. public Transform player;
  9. public float MaxDistance = 3;
  10.  
  11. // Use this for initialization
  12. void Start ()
  13. {
  14. player = GameObject.FindGameObjectWithTag("Player").transform;
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update ()
  19. {
  20.  
  21. _timeout += Time.deltaTime;
  22. if(Input.GetKey(KeyCode.E)&&_timeout>Timeout&&Vector3.Distance(transform.position, player.transform.position)<MaxDistance)
  23. {
  24.  
  25. networkView.RPC("Door",RPCMode.Server);
  26.  
  27. }
  28. }
  29.  
  30. [RPC]
  31. void Door () {
  32. networkView.RPC("Client_OpenDoor",RPCMode.All);
  33. }
  34. [RPC]
  35. void Client_OpenDoor () {
  36. _timeout = 0;
  37. open = !open;
  38. if(open == true)
  39. {
  40. transform.animation.CrossFade("open");
  41. Debug.Log("LOG: open door");
  42. }
  43. if(open == false)
  44. {
  45. transform.animation.CrossFade("close");
  46. Debug.Log("LOG: close door");
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement