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 Eqric · Jan 13, 2013 at 09:25 PM · cameranetworkinginstantiateprefabstrange

Instantiate prefab, strange problem

Hi, i am making a network game and when a player join the world, the server tell the client to instantiate the prefab into a position in the world.

This work fine, when someone log in the model are shown at correct position. The problem occur when i look at the new spawned model and then look away. When i look back where the model have been, the model have changed position far far away. The strange thing is that the model is there as long as i keep my camera view on it, but when its out of view it gets a new position (random) often very very far away.

Any idea what can cause this strange problem? I instantiate using this code.

 Instantiate(newPlayer.getPlayerModel(),newPlayer.getPosition(),newPlayer.getRotation());

and i get the gameobject by using this code:

 string temp = PrefabId.ToString();
 PlayerModel =(GameObject)Resources.Load("PlayerPrefab/"+temp);

*Note: The position seems to be (at least the root ) the same but it's rendered in a different position...

*Note: If you look at it again after first time and then look away, it get rendered in a new random location but the position on the transform in the same.

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
2
Best Answer

Answer by robertbu · Jan 14, 2013 at 06:14 AM

When I have a strange problem like this one, I ususaly start thowing "stuff" at it to see if I cannot narrow down what is going on. Here is a laundry list of things you might try for this issue:

  1. Look at all the positions and scales for the parent game object and all its children. Do any change between looking away and looking back?

  2. Change the shader for the material used in rendering the object.

  3. Disable any additional cameras in the scene.

  4. Examine the camera when looking away and then back. Do any settings change?

  5. Set the position of the new game object manually right after the object is created.

  6. Create a simple object in the editor (cube for example). Place this game object at or near the coordiantes you use when you Instantiate the prefab. Does it appear in the same place? Does it also move when you look away?

  7. Reset the position of the newly created game object half a second after creation to the position used when you Instantiated it.

  8. If your prefab is complex, try a very simple prefab in its place.

  9. Drag a copy of the prefab into the scene. Try Instantiating the scene copy instead of the copy you got using Resources.Load()

Good luck.

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 Eqric · Jan 14, 2013 at 08:54 AM 0
Share

Thanks mate, it seems to be a broken prefab that use dx11, fixed it by re importing the model and then made a new prefab.

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

9 People are following this question.

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

Related Questions

Spawning problems with cameras 1 Answer

Can't set camera target after instantiating a prefab(like respawn) 0 Answers

Get transform of instantiated Prefab; Help appreciated. 1 Answer

[UNET] How to know the connectionID of a player ? 2 Answers

Instantiating a prefab that needs a public reference to another prefab 3 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