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 jaja1 · Oct 24, 2014 at 08:47 AM · c#prefabs

[SOLVED] Problem rendering prefab model in game

I created a prefab with an fbx model and some other components like scripts etc. I can drag and drop the prefab into the scene view and I can see the model just fine...it even animates. If I open the game I still see that prefab that I dropped into the scene.

But when I try to instantiate the prefab using a c# script I do not see the model. Not even the labels that are supposed to appear above the object's head show up.

Why does this happen?

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 Graham-Dunnett ♦♦ · Oct 24, 2014 at 08:48 AM 0
Share

Does the instantiated prefab appear in the hierarchy view? $$anonymous$$aybe it's in the game, but not somewhere the camera can see it?

avatar image PvTGreg · Oct 24, 2014 at 10:56 AM 0
Share

show us the instantiate script

avatar image jaja1 · Oct 24, 2014 at 10:03 PM 0
Share

Thanks for the replies so far guys. Here is the else if block where the local character is instantiated. This script worked fine with a 2d sprite but I decided to make my game in 3d ins$$anonymous$$d, so I totally re-made the prefab this time with a 3d model. And yes, the prefab does appear in the hierarchy view when this block of code is called. I just cant see the model when I instantiate it.

 else if (tempHash.Contains$$anonymous$$ey(current_char))//for the current user's client
                 {
                     //create a new instance of the player
                     THISplayer = (GameObject)Instantiate(Resources.Load("playerPrefab"));
 
                     THISplayer.name = cachename;
                     player_data _playerData = THISplayer.GetComponent<player_data>();
 
                     //cache player data variables
                     _playerData.OtherCharName = cachename;
                     _playerData.gender = cc_gender;
                     _playerData.race = cc_race;
 
                     //set the last known position of the character from the database
                     THISplayer.transform.position = new Vector3((float)tempD[1], (float)tempD[2], (float)tempD[3]);
 
                     //get all character data from the server that does not belong to this client
                     RequestAllOtherCharData();
 
                     //initialize player components for this client
                     THISplayer.GetComponentInChildren<Camera> ().enabled = true;
                     THISplayer.GetComponent<player_controller> ().enabled = true;
 
                     _THISpdata = GameObject.Find(current_char).GetComponent<player_data>();
                 }
avatar image jaja1 · Oct 26, 2014 at 01:08 AM 0
Share

found that the model is being rendered but it not in the camera view...not sure why yet.

3 Replies

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

Answer by jaja1 · Oct 26, 2014 at 08:14 PM

Solved: the mesh, bones and camera had to be realigned with each other since they were all children of the same game object.

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 jabez · Oct 26, 2014 at 01:20 AM

Click the root of the player & under the skin mesh renderer check update when off screen alt text


untitled.png (14.5 kB)
Comment
Add comment · Show 1 · 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 jaja1 · Oct 26, 2014 at 03:58 AM 0
Share

That was actually unchecked. I checked it but the problem still persists. I also checked to see if the change was applied in game and it was :/ PS. Is it a problem to have the skinned mesh as a child of the prefab?...thats how the prefab was created.alt text

untitled.png (38.3 kB)
avatar image
0

Answer by jctz · Oct 26, 2014 at 05:29 AM

Maybe check the gameobject's layer and make sure it's not being modified by code and now being culled by the camera?

Comment
Add comment · Show 2 · 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 jaja1 · Oct 26, 2014 at 05:47 AM 0
Share

I do not believe it is a culling issue as you can see in the attachment. And as I said I did check earlier with a second client that the model is being rendered but it is way off from the camera view. alt text

untitled.png (44.9 kB)
avatar image jaja1 · Oct 26, 2014 at 03:17 PM 0
Share

sorry to keep bumping but I'm still trying to figure it out and no luck :/

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

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to render a particle system with a preset particle system in a prefab? 0 Answers

How can I prevent a prefab script from affecting all instances when entering a collider? 1 Answer

Reduce Physics2D Lag 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