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 nowhereman · Sep 05, 2011 at 08:08 AM · prefablinerenderernetwork.instantiate

Network.Instantiate a Non-prefab

I've been trying to figure this one out for hours with no luck. I'm trying to Instantiate a line renderer across a networked game, but I need to calculate how one player draws the line and then have it instantiated across the network. My code looks something like this:

 if(Input.GetButtonDown("Fire1")){
         newLine = Instantiate(line, transform.position, transform.rotation);
         LR = newLine.GetComponent(LineRenderer);
         LR.SetVertexCount(1);
         point1 = FindNewPoint();
         LR.SetPosition(0, point1);
     }
 
     if(Input.GetButtonUp("Fire1")){
         LR.SetVertexCount(2);
         point2 = FindNewPoint();
         LR.SetPosition(1, point2);
         
         
         EditorUtility.ReplacePrefab(newLine, Resources.Load("RecalculatedLineRenderer"));
         Destroy(newLine);
         
         canDraw = false;
         Network.Instantiate(Resources.Load("RecalculatedLineRenderer"),transform.position, transform.rotation, 0);
         GC.networkView.RPC("CalculateAngle", RPCMode.AllBuffered, point1.x, point1.y, point2.x, point2.y);

The problem is I don't know how to access the point vectors of the line renderer after it's been created, as far as I know the only way to change those points is through the LineRenderer.SetPosition();, otherwise I'd be able to instantiate across the network initially then send out an RPC and change those points after doing the calculations for drawing the line.

So I went to this method of instantiating locally, doing the calculations, then replacing the prefab with EditorUtility.ReplacePrefab() and then doing the Network.Instantiate(). I thought it was working till I tried to make a build to test the networking. I guess you can't make a build if you use EditorUtility >.< . This would be easier if I could just do Network.Instantiate(newLine : GameObject, etc...); but unlike a regular Instantiate(), Unity will only do prefabs for Network.Instantiate()... Is there something I'm missing? or any ideas on how I could pull this off?

Comment
Add comment
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

1 Reply

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

Answer by nowhereman · Sep 05, 2011 at 08:26 AM

GAAAAh. Thought about it a little more after posting that. I could just instantiate then do an RPC call and do LineRenderer.SetPosition(); So I just had to add a line with

  newLine.networkView.RPC("DrawLine", RPCMode.AllBuffered, point1, point2);

Did not think that one through all the way...>.<

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

2 People are following this question.

avatar image avatar image

Related Questions

How do i access a network instantiated object? 1 Answer

Bullet tracers - instanced prefabs vs LineRenderer? 0 Answers

Instantiate cube on network 0 Answers

Prefab not spawning on client correctly 1 Answer

Network.Instantiate received non-matching number of view id's as contained in prefab 2 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