void OnMouseDown() { if (!isPosses) { PlayerMovement player = (PlayerMovement)FindObjectOfType(typeof(PlayerMovement)); PlayerPoses playerPos = (PlayerPoses)FindObjectOfType(typeof(PlayerPoses)); if (roomBelong.setRoom == playerPos.room) { player.Stop(); playerPos.PossesOject(player, this); } else { Debug.Log("Your in other room"); } } }
void Start() { playerPos = (PlayerPoses)FindObjectOfType(typeof(PlayerPoses)); agent = GetComponent <NavMeshAgent>(); allowToMove = true; }