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
1
Question by Eyeshock · Dec 01, 2012 at 12:43 PM · networkingtransformscaleloadlevel

Why does localscale of transform set randomly to (0,1,1) and (0,0,0) on level load?

Basically, I'm building a multi-player RPG and everything seems to go fine with the networking. Except that RANDOMLY a Prefab will be set to a scale of either (0,1,1) or (0,0,0). It is never the local player's prefab, and it happens more on the host than the clients. Just did some debugs on local and world scale: both claim it's set to 1.0, 1.0, 1.0 even when I see it as 0, 0, 0 in the inspector - and hardcoding after instantiation and level-load don't seem to matter...(2nd script happens after level load setting spawn point)

Really, none of that should matter since I use the same RPC to instantiate for host and client.

 void Client_LoadMultiplayerScene(string scene, int prefix)
 {
 
 // Create Player Prefab
 GameReference.localPlayerObject = Network.Instantiate(playerCharacterPrefab, Vector3.zero, Quaternion.identity, 0) as GameObject;
 GameReference.localPlayerObject.name = GameReference.playerCharacterScript.Name;
 GameReference.localPlayerObject.transform.localSca le.Set(1,1,1);
 
 
 // So we only recieve messages for new prefix
 Network.SetLevelPrefix(prefix);
 
 
 Application.LoadLevel(scene);
 
 }

So this function instantiates the player prefabs and adds them to the list of players. The Prefabs have DoNotDestroyOnLoad called to preserve their stats and data. I've been having this problem for a while so I decided to try and hard code to localScale here, where I move everyone to the spawn point:

 // Move Players to Level Spawnpoint
 for(int cnt = 0; cnt < GameReference.multiplayerManagerScript.NetworkedPl ayerPrefabs.Count; cnt++)
 {
 GameReference.multiplayerManagerScript.NetworkedPl ayerPrefabs[cnt].transform.localScale.Set(1,1,1);
 GameReference.multiplayerManagerScript.NetworkedPl ayerPrefabs[cnt].transform.position = spawnPoint.transform.position; 
 }

The players all get moved to the spawn point, but their localScale still seems totally random. Maybe I just hard coded it wrong, but honestly I don't see why I should have to hard code it at all. Perhaps it's some flaw with Network.Instantiate? I am also using the PlayerRemote and PlayerLocal scripts for interpolation from the unity wiki (perhaps something wrong in there?)

This problem has haunting me for a while now. I workaround it by always hosting with editor execution and simply setting the scale to 1,1,1 in the inspector, but obviously I can't keep doing that. :p

Thanks to anyone who takes the time. Cheers.

  • Erik

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 HoneyFox · Feb 19, 2014 at 10:32 AM

I met some similar issue too. It seems like the localScale.Set() function takes the parents' scale into consideration as well. You might try:

  transform.localScale = new Vector3(0.0f, 0.0f, 0.0f);

at least this works for me.

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

11 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

Related Questions

uGUI keep position and size of GUI elements when anchors change 3 Answers

Saving default transform of an object c# 1 Answer

Networking: how to sync NetworkViewIDs for level objects on peers? 4 Answers

Networking Help Needed 0 Answers

Networking LoadLevel - player connect 2 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