Advertisement
Guest User

Skrypt

a guest
Apr 26th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using UnityEngine;
  6.  
  7. public class zaznaczanie : MonoBehaviour {
  8.  
  9. public void unselectAll() {
  10.  
  11. foreach (GameObject player in mercenaries) {
  12.  
  13. Player.GetComponent<playercontroller> ().unselect Player ();
  14.  
  15. }
  16.  
  17. }
  18.  
  19. private GameController gc;
  20.  
  21. void Start () {
  22.  
  23. gc = GameObject.Find ("GameController").GetComponent<gamecontroller>();
  24.  
  25. }
  26.  
  27. void Update () {
  28.  
  29. if (Input.GetMouseButtonDown(0)){
  30.  
  31. Ray ray = gameObject.GetComponent<camera>().ScreenPointToRay(Input.mousePosition);
  32.  
  33. RaycastHit hit;
  34.  
  35. if (Physics.Raycast(ray, out hit)) {
  36.  
  37. if (hit.transform.gameObject.tag == "Player") {
  38.  
  39. Transform selected = hit.transform;
  40.  
  41. gc.unselectAll ();
  42.  
  43. selected.SendMessage ("selectPlayer");
  44.  
  45. }
  46.  
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement