Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Brachiosaurus · Mar 16, 2017 at 08:30 PM · editortransformbuildmultiplayerworking

Photon multiplayer game working in editor but not in build.

There are two problems I appear to be having at once.

Problem #1: I made a script to scatter gameobjects throughout a set radius, and it works beautifully in the editor, but does absolutely nothing in the build. If I start a photon room in the editor, and then join it in a build, however, the objects will be there in the world, but if I start a room in the build they simply do not spawn. Here is the script:

 using UnityEngine;
 using System.Collections;
 
 public class SpawnItems : MonoBehaviour {
     
     public GameObject Item;
     public int spawnNum = 12;
     public int negX = -155;
     public int posX = 155;
     public int negZ = -155;
     public int posZ = 155;
 
     void spawn()
     {
         for(int i = 0; i <spawnNum; i++)
         {
             Vector3 ItemPos = new Vector3(this.transform.position.x + Random.Range(negX, posX), this.transform.position.y + Random.Range(0.0f, 0.0f), this.transform.position.z + Random.Range(negZ, posZ));
             GameObject ItemGO = (GameObject)PhotonNetwork.Instantiate(Item.gameObject.name,ItemPos,Quaternion.identity, 0); //PhotonNetwork.
             
         }
     }
     // Use this for initialization
     
      void OnCreatedRoom()
  {
         spawn();
     
  }
     
     // Update is called once per frame
     void Update () {
     
     }
 }

Problem #2: I also made a (totally unrelated) script which is placed on an object so that it would move along the Terrain at a raycast hit sent from the center of the player's view. It was meant to be a building system, like in games like rust, where a transparent preview of an object being built exists where the object will be placed, then, when the player clicks, it spawns the object in its place. Again, it works like a charm, but only in the editor. In the built edition of the game, the ghost object (the preview) does not move at all. Here is the script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlaceThingC : MonoBehaviour {
 
 
 public Transform prefab;
 public float speed = 1.0f;
 public Camera PlayerCamera;
 
 
 void  Start (){
     
 }
 
 void  Update (){
     
     Ray ray = PlayerCamera.ScreenPointToRay(Input.mousePosition); //camera.main.ScreenPointToRay
     RaycastHit hit;
     Vector3 euler = this.transform.rotation.eulerAngles; //Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z);
     
     if (Physics.Raycast(ray, out hit,Mathf.Infinity)) {
         if(hit.collider.tag == "Terrain"){
             
             if (Input.GetKey(KeyCode.E)) {
                 transform.Rotate(Vector3.up * speed * Time.deltaTime);
             }
             
             if (Input.GetKey(KeyCode.Q)) {
                 transform.Rotate(-Vector3.up * speed * Time.deltaTime);
             }
             
             transform.position = hit.point;
             
             if (Input.GetMouseButtonDown(0)) {
                 PhotonNetwork.Instantiate (prefab.gameObject.name, hit.point, Quaternion.Euler(euler.x,euler.y,euler.z), 0);
                 this.transform.gameObject.SetActive(false);
             }
         }
     }
 }
 
 
 
 [PunRPC]
 void  Test (){}
 }

Thanks in advance to anyone who bothers to help me out here.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brachiosaurus · Mar 22, 2017 at 01:23 AM 0
Share

Anybody There?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nicolas4677 · Nov 19, 2018 at 09:08 PM

Het, did you get a solution? I'm having same error.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Setting different values on editor and build 1 Answer

Distribute terrain in zones 3 Answers

Discrepancy Between Editor and Build World Transform Positions 1 Answer

How to sync child objects of a transform in multiplayer 3 Answers

Materials breaking in built project (but not in editor play mode) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges