Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.


  • Content Count

  • Joined

  • Last visited

Community Reputation

2 Neutral


About jag9980

  • Rank

Profile Information

  • Gender
  • Location:
  • Interests

Recent Profile Visitors

616 profile views
  1. hey, So iv'e got a procedural game , and every item that gets placed in the level is stored in a string, along with its rotation and position. Then this string is stored in a database. The string goes like this for an example - string all = "itemname" + "posx" + "posy" + "posz" + "rotx" + "roty" +"rotz" + "itemname2"... and so on it works fine, but i was wondering if there is a better approach to this.The number of items depends on the player and can be in thousands, would that become and issue in future? Is there a better way to do this?
  2. so i have a multiplayer game with about 4 players in each session, but A LOT of enemies. All enemies have a navmesh agent . Whats the best way to sync all the enemies positions with all the players without causing anylags? i am using photon network.
  3. public void OnJoinedRoom(){ t = GameObject.Find ("ground").GetComponent<Terrain> (); if (PhotonNetwork.isMasterClient) { //spawn_items (); for (int i =0; i < 1000; i ++) managenaturespawn(); } } public void managenaturespawn(){ if (PhotonNetwork.isMasterClient) { pos = mainpoint.transform.position + Random.insideUnitSphere * 440; pos.y = t.SampleHeight (pos); int chose = Random.Range (0, natureitems.Count); GetComponent<PhotonView>().RPC("universalspawn",PhotonTargets.AllBuffered,pos,chose); } } [PunRPC] public void universalspawn(Vector3 pos , int choice){ GameObject newitem = (GameObject)Instantiate ((GameObject)Resources.Load ("objects/" + natureitems [choice]), pos, Quaternion.identity); allthethings.Add (newitem); newitem.GetComponent<item_identification> ().id = allthethings.Count - 1; } Hello, so we are making an android game which requires the master client to instantiate about 1000 gameobjects and sync it with the clients.But the game gets stuck on android devices when a player joins the game. No issue occurs on PC however. Is there a better way to do this?
  4. Alright, so now i am using a list for the gameobjects instantiated.... and a custom id type system. But the function gets random positions of rocks for every player. ( They are not the same for all players) . Is the function supposed to be called differently? public List<GameObject> allthethings; public void OnJoinedRoom(){ if (PhotonNetwork.isMasterClient) { t = GameObject.Find ("ground").GetComponent<Terrain> (); for (int i =0; i < 1000; i ++) GetComponent<PhotonView>().RPC("managenaturespawn",PhotonTargets.AllBuffered); } } [PunRPC] public void managenaturespawn(){ pos = mainpoint.transform.position + Random.insideUnitSphere * 1000; pos.y = t.SampleHeight (pos); int chose = Random.Range (0, natureitems.Count); GameObject newitem = ( GameObject) Instantiate ((GameObject)Resources.Load ("rocks"), pos, Quaternion.identity); allthethings.Add (newitem); newitem.GetComponent<item_identification> ().id = allthethings.Count - 1; }
  5. yes, the items will be distributed at the start of the game. The thing is all of the items are interact-able, hence all of them require a photon id. If a make a prefab of 100 rocks and continue, i wont be able to interact with the required one.Whats the better approach?
  6. hello, ive been making a sandbox multiplayer game using photon. And i have to distribute a large number of items ( over 10,000 ) on the terrain. Since its multiplayer, what is a good way to instantiate a large number of items from the master client? public void managenaturespawn(){ pos = mainpoint.transform.position + Random.insideUnitSphere * 1000; pos.y = t.SampleHeight (pos); // t is the terrain PhotonNetwork.Instantiate ("objects/rock" ,pos, transform.rotation,0); // this function is called by the master client, and each object/rock has a photonnewtworkview. }
  7. so i just came across this video and figured nobody has shared it yet :)i cant get it to download tho . http://adf.ly/1LL55S
  8. so i have this code for my character, but the jumping doesnt work. When i press space, the character simply teleports to a higher position void FixedUpdate() { moveDirection = new Vector3 (Input.GetAxis ("Horizontal") / 2, 0, Input.GetAxis ("Vertical")); moveDirection = transform.TransformDirection (moveDirection); moveDirection *= speed * sppedmultiplier; if ((Input.GetAxis ("Vertical") > 0.5f) && running) sppedmultiplier = 2; else sppedmultiplier = 1; if (GetComponent<CharacterController> ().isGrounded) { if (Input.GetButtonDown ("Jump")) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; GetComponent<CharacterController> ().Move (moveDirection * Time.deltaTime); }
  9. hi all , so ive been getting this error even though i keep returning gameobjects.. heres the code - public GameObject checkdesiredtarget(){ int locaiton = 0; int max = 0; for (int i = 0; i < inrange.Count; i ++) { if ( inrange[i].GetComponent<AGRO>().agro > max){ max =inrange[i].GetComponent<AGRO>().agro; locaiton = i; } } if ( inrange[locaiton]) return inrange[locaiton]; if (hasseenplayer) return lastseen; if (inrange.Count == 0) return null; } error -not all code paths return a value
  10. oh yea thanx alot!
  11. hey, ive been having trouble passing my coroutine function over the network...it works fine offline but i am not able to call the photonnetwork courotine function. it gives me compiation errors. where am i going wrong? GetComponent<PhotonView>().StartCoroutine("ChopItDown",(closestTreeIndex,terrain,closestTreePosition))); // this gives me errors StartCoroutine(ChopItDown(closestTreeIndex, terrain, closestTreePosition)); // this works just fine
  12. jag9980


    i know how this works, but i want to capture only a certain area of the screen , so i tried this code but this captures all of the screen - public Texture tol; public float w; public float h; public float px; public float py; private Texture2D m_Texture; void Start(){ m_Texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true); } void OnGUI(){ if (GUI.Button(new Rect(20, 20, 150, 100), "ReadPixels")) { kol (); } } IEnumerator kol(){ yield return new WaitForEndOfFrame(); m_Texture.ReadPixels(new Rect(Screen.width/px, Screen.height/py, Screen.width/w, Screen.height/h), 0, 0, true); m_Texture.Apply(); byte[] bytes = m_Texture.EncodeToPNG(); File.WriteAllBytes( "Assets/screenshot.png", bytes); } }
  13. jag9980


    so i need to take a screenshot for my game but cant figure out how to do it. Ive used this script. But it doesnt save the screenshot in the assets folder. What am i doing wrong? import System.IO; function Start () { UploadPNG(); } function UploadPNG () { yield WaitForEndOfFrame(); var width = Screen.width; var height = Screen.height; var tex = new Texture2D (width, height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels (Rect(0, 0, width, height), 0, 0); tex.Apply (); // Encode texture into PNG var bytes = tex.EncodeToPNG(); Destroy (tex); File.WriteAllBytes( "Assets/screenshot.png", bytes);
  • Create New...