Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Wraifen_09 · Mar 26, 2014 at 06:02 AM · instantiateobjectnetworknetworkview

How to update a script to a network script

Hey, sorry to ask but I'm new at this and while my script works perfectly I've ran into an issue. As such I've made a basic script that creates a prefab object at the ray cast hit location and while it appears to the person whose placed it, I have no idea on how to make it appear for other players in the game. As all they see is when the placer is standing on it they are floating.....anyway I've tried a couple solutions yet I can never get it too work, so if anyone could please tell me how I would go about this, I would be most grateful.

 using UnityEngine;
 using System.Collections;
 
 public class delete : MonoBehaviour {
 
     RaycastHit hit;
 
     public Transform prefab;
 
     // Use this for initialization
     void Start () {
 
     }
     
     // Update is called once per frame
     void Update () {
 
                 Ray ray = camera.ViewportPointToRay (new Vector3 (0.5F, 0.5F, 0));
 
                 Vector3 G = new Vector3 (Mathf.Round (hit.point.x), Mathf.Ceil (hit.point.y), Mathf.Round (hit.point.z));
 
                 if (Physics.Raycast (ray, out hit)) {
 
                         if (Input.GetMouseButtonDown (2)) {
                                 Destroy (hit.collider.gameObject);
 
             
                         }
 
                         if (Input.GetMouseButtonDown (1)) {
                                 Instantiate (prefab, G, Quaternion.identity);
                         }
 
                         if (Input.GetMouseButton (1)) {
                                 animation.Play ("right_hand_build 1");
                         }
 
 
             }
     }
 }
 

 
Comment
Add comment · Show 2
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 whydoidoit · Mar 27, 2014 at 06:16 AM 1
Share

You will need to send an RPC call to the other players getting them to see what you need - if you are just looking for the created object to appear you should use Network.Instantiate

avatar image Wraifen_09 · Mar 27, 2014 at 08:47 AM 0
Share

cheers for the reply, however i've tried this before and I ran into an issue about overload, how would I be able to work around this...hahaha sorry

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by fholm · Mar 27, 2014 at 09:35 AM

You should use PhotonNetwork.Instantiate

Comment
Add comment · Show 3 · 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
avatar image Wraifen_09 · Mar 27, 2014 at 10:54 PM 0
Share

I've tried this and now are met with it stating that I'm not connected to the server however I'm using photon if that affects anything.

avatar image fholm · Mar 28, 2014 at 05:05 AM 0
Share

PhotonNetwork.Instantiate

avatar image Wraifen_09 · Mar 28, 2014 at 06:40 AM 0
Share

cheers, that work hahaha I feel like a fool but thanks

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

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you authoritatively control objects that were already in the scene, and not Network.Instantiated? 1 Answer

Player 2 not spawning 1 Answer

Changing a network object. 1 Answer

Disabling child camera over network 1 Answer

[FIXED] Sync crate position over network 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