Advertisement
Guest User

ReceiveMovement.cs

a guest
Aug 3rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class RecievedMovement : MonoBehaviour {
  5.  
  6.  
  7. Vector3 newposition;
  8. public float speed;
  9. public float walkRange;
  10.  
  11. public GameObject graphics;
  12.  
  13.  
  14. void Start () {
  15.  
  16. newposition = this.transform.position;
  17.  
  18. }
  19.  
  20.  
  21. void Update () {
  22.  
  23. if (Vector3.Distance (newposition, this.transform.position) > walkRange) {
  24. this.transform.position = Vector3.MoveTowards(this.transform.position, newposition, speed * Time.deltaTime);
  25. Quaternion transRot = Quaternion.LookRotation(newposition - this.transform.position, Vector3.up);
  26. graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.7f);
  27. }
  28. }
  29.  
  30. [PunRPC]
  31. public void RecievedMove(Vector3 movePos){
  32. newposition = movePos;
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement