• 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 WingedCross · Jul 18, 2012 at 07:42 AM · errorcomponentcloneexceptionmissing

Missing Component Exception Error

When I try to run this code, I received a Missing Component Exception. It said "There is no 'NetworkView' attached to the "Player(Clone)" game object, but a script is trying to access it. You probably need to add a NetworkView to the game object "Player(Clone)".

How do I add a NetworkView to the game object "Player(Clone)"?

  void spawnPlayer() {
  Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0 );
 }

     void  Update(){
  if(networkView.isMine){
  moveDirection = new Vector3(Input.GetAxis ("Horizontal") * speed * Time.deltaTime, -gravity * Time.deltaTime, Input.GetAxis("Vertical") * speed * Time.deltaTime);
  moveDirection = transform.TransformDirection (moveDirection);
  
  chc.Move(moveDirection);

}

I have the Network Manager script attached to the Network Manager game oject within the scene. And I have the Player (Prefab) attached. But when even I start the game, it makes a Player Clone prefab and then gives me this error. I'm stuck can anybody please help me?

Also when I run my game, the Player prefab is created as Player(Clone) and there is no Network View attached to the game object, so it doesn't run.

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 WingedCross · Jul 18, 2012 at 04:48 AM 0
Share

Also this is obviously in C#.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by cupsster · Jul 18, 2012 at 09:56 AM

Select your object then go to Component > Miscellaneous > Network View This will add required component to your script, or you can use at begining of your script:


 [RequireComponent (typeof (NetworkView))]
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
avatar image
2

Answer by Kryptos · Jul 18, 2012 at 10:01 AM

You need to add a Networkview component to your Player prefab.

You can also do it automatically by adding the RequireComponent attribute before the declaration of the class in your script file:

 [RequireComponent (typeof(NetworkView))]
 public class Player : MonoBehaviour {

 }

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
avatar image
0

Answer by senad · Jul 18, 2012 at 09:42 AM

Is there a NetworkView attached to your Player prefab? If not, create a new one and attach it.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

Missing component exception in unity. there is no animation component attached but a script is trying to access it. 1 Answer

Unity 5.0, ambiguous component reference? 1 Answer

GetComponent of ALL clones? 2 Answers

Menu Component/MaterialUI/EZAnim can't be checked because doesn't exist 2 Answers

Help with error: UnassignedReferenceException 5 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