Guest User

Untitled

a guest
Dec 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. public class Player : MonoBehaviour {
  2. public GameObject ComingPersonModel;
  3. GameObject _ComingPersonModelClone;
  4. GameObject gameManager;
  5.  
  6. [HideInInspector]
  7. public bool isTouchComingPerson = false;
  8. // Use this for initialization
  9. void Start () {
  10. gameManager = GameObject.FindWithTag("GameManager");
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update () {
  15. MouseDragToMove();
  16. }
  17. void MouseDragToMove()
  18. {
  19. if(Input.GetMouseButton(0))
  20. {
  21. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  22.  
  23. RaycastHit hit = new RaycastHit();
  24. //&& hit.collider.gameObject.tag == "Player"
  25. if(Physics.Raycast(ray,out hit) )
  26. {
  27. Debug.DrawLine(ray.origin, hit.point, Color.red);
  28.  
  29. if(hit.collider.gameObject.tag == "Player")
  30. this.transform.position = new Vector3(hit.point.x,transform.parent.position.y + 1f,hit.point.z);
  31.  
  32. if (hit.collider.gameObject.tag == "ComingPerson" && Input.GetMouseButtonDown(0))
  33. {
  34. Debug.Log("Pressed Coming Person");
  35. isTouchComingPerson = true;
  36.  
  37. gameManager.GetComponent<GameManager>().RemoveAllComingPerson();
  38.  
  39. _ComingPersonModelClone = Instantiate(ComingPersonModel, hit.collider.gameObject.transform.position,hit.collider.transform.rotation);
  40. _ComingPersonModelClone.transform.parent = this.transform.parent;
  41. }
  42. }
  43. }
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment