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 /
  • Help Room /
avatar image
0
Question by sdebaun · Oct 28, 2015 at 08:00 PM · networkingcontrolleraddcomponent

How to add network components to entities at runtime?

I am trying to figure out how to dynamically add network components to game objects that are managed by the network.

I started unity about a month ago, and I started writing all sorts of components that I then wired together in the editor. I have now reached the point where I realize how cumbersome it is to manage a complex project that is built that way.

I am now going through and trying to create "controller" mono behaviors for all of my entities. The intent is that the controller will use AddComponent to add the behaviors it needs. So instead of creating a prefab with a dozen components that are all wired together in the editor, I create a prefab with a single controller component. That controller then adds components like a rigid body, collider, etc., and wires them together via code.

This works well until I get to networking the entity. It seems like network components need to be part of the prefab or they don't work at all. I tried using OnStartServer and OnStartClient to add NetworkTransform components, but the transform wasn't synchronizing. I could add the NetworkTransform to the prefab, but then it needs a rigid body... and I suspect other network behaviors would also need to be there. And then I'm right back where I started, with a large, opaque prefab.

I have no problems getting networked entities working with monolithic prefabs and the built in network manager. But when I try the " grown up" way, by adding components in code, it goes pear - shaped. Is what I'm attempting even possible? How deep do I have to go into unity's networking in order to do this? Is there a way that involves the sparsely documented ClientScene methods? Do I need to somehow make the network server aware of the newly added NetworkTransform?

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

Answer by WavyRancheros · Aug 23, 2017 at 10:58 AM

I would like to know the answer to that as well.

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

38 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 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 to fix: transform.position assign attempt for 'Player(Clone)' is not valid. Input position is { NaN, NaN, NaN }. UnityEngine.Transform:Translate(Vector3) FloatingPlayer2DController:Update() (at Assets/FloatingPlayer2DController.cs:59) 2 Answers

Is there a way to use a phone as a controller? 0 Answers

Using a Phone as a Remote Control and Cross Platform Input 0 Answers

Multi Controller Support for UI 0 Answers

UNET : DON'T sync players 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