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 KiyoriAnoyui · Sep 15, 2012 at 12:41 AM · error

What is this error and how can I fix it?

Ok, so I am trying to make a character customization screen, where you can change clothes, height, and skin color and whatnot. And I am having a lot of trouble with the changing in faces and skin color, for each thing there is the same error.

MissingComponentException: There is no 'Renderer' attached to the "PC" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "PC". Or your script needs to check if the component is attached before using it.

Here is the code i am using for the skin color. Is there something I should add or something I am not doing right?

Any help would be awesome! Thanks

public void LoadSkinColor() { characterMaterialMesh.renderer.materials[ (int)CharacterMaterialIndex.Face ].mainTexture = Resources.Load( GameSetting2.HEAD_TEXTURE_PATH + "head_" + GameSetting2.LoadHeadIndex() + "_" + GameSetting2.LoadSkinColor() + ".human") as Texture; }

Comment
Add comment · Show 4
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 voncarp · Sep 15, 2012 at 10:16 AM 1
Share

For starters, try adding a mesh renderer to the pc object. Looks like Bergzerg's stuff.

avatar image DESTRUKTORR · Sep 15, 2012 at 11:12 AM 0
Share

Better suggestion: For starters, try entering your code in a code block, with the button with "101010" on it, so we can read it easier. But yeah, like voncarp said, you need to add a $$anonymous$$eshRenderer component to the object named "PC." To do that, at least the easiest way, select the GameObject in your hierarchy, and under the "Component" menu, at the top, select "$$anonymous$$esh" then "$$anonymous$$eshRenderer."

Good luck!

avatar image KiyoriAnoyui · Sep 15, 2012 at 05:45 PM 0
Share

I am a self admitting noob. So thank you both for the help. I will be sure to put the code like that next time. And yes voncarp, it is from his tutorial series. Since your familiar with it, maybe you can help me, it indexes through the faces, I can tell via debug, but the actual face on the character does not change.

Here is most of the code for the face changer.

public static void ChangeHeadIndex( int index ) { headIndex = index;

// Debug.Log( "Head set to index: " + headIndex ); _update = true;

 }

Below is where the error takes me.

public void UpdateHead() { head$$anonymous$$aterial = PC.Instance.character$$anonymous$$aterial$$anonymous$$esh.renderer.materials[4]; //4 is the index of the material for the head/face texture head$$anonymous$$aterial.mainTexture = Resources.Load( GameSetting2.HEAD_TEXTURE_PATH + "head" + headIndex + "" + skinColor + ".human") as Texture;

There is no error for the muscular character, but there is for the fat character.

This is the error I get.

IndexOutOfRangeException: Array index is out of range. Player$$anonymous$$odelCustomization.UpdateHead () (at Assets/_Scripts/Character/Character Customization/Player$$anonymous$$odelCustomization.cs:130) Player$$anonymous$$odelCustomization.Update () (at Assets/_Scripts/Character/Character Customization/Player$$anonymous$$odelCustomization.cs:59)

Even though I dont get an error for the muscular character, the face still doesn't change. I'm just not sure what the problem is.

avatar image voncarp · Sep 16, 2012 at 12:55 AM 0
Share

Its tough to answer as is could be a number of different problems. At this particular section in his tutorial you have to have a a few different areas set up properly for it to work. Your problem here might be that your models and gameobjects need to be named properly and your resource folder needs the exact folders and number of textures to be set up exactly how he sets it up in the tutorial and also based on the path in the gamesettings2.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by justinl · Sep 15, 2012 at 05:26 PM

As Voncarp said, add a MeshRenderer component to the GameObject named "PC".

I'm simply pasting this answer here so that the question can be marked as "Answered". If either of the original guys who answered the question want the points feel free to post your answer officially and I'll delete this one.

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 ReK Project · Jan 04, 2013 at 07:10 AM

The problem is that if you are using a later version of frogames commoners and warriors, they use only one material for the character mesh instead of 5 like in the version petey is using.

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

13 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

Related Questions

A node in a childnode? 1 Answer

Error or Bug in unity 0 Answers

When I kill one enemy, the rest disapear, but still shoot 1 Answer

Invalid Characters in Path 1 Answer

2D toolkit scripting error - Very Basic Stuff 1 Answer


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