Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 jaxsonp10 · Jan 24, 2016 at 04:05 PM · cameranetworkingtransformtransform.position

How do I update values and the transform of an object on the server's and client's side?

I'm making a very simple game, where the camera automatically scrolls down simply using gravity, and the players have to keep up with it. I'm sure you've all played a very similar game, where you have to go through holes in the floor to the next floor and the next until you can't keep up and lose.

Regardless, the issue I'm having is resulting from wanting to be able to restart the game at the touch of a key. Now, to do this, I've made a code to were the camera will return to it's original position, and it will disable gravity on it's Rigidbody, so the camera will stay in place until it's ready to scroll again. I also have included a few lines of code to move all the players to the original spawn point again, where they can then move from to start the game. The script looks like this:

 function FixedUpdate () {
 
     var camera = gameObject.Find("Camera").GetComponent.<Rigidbody>();
 
         if(Input.GetKey("k"))
         {
             var players = GameObject.FindGameObjectsWithTag("Player");
             
             for(var p = 0; p <players.length ; p++ ) 
             {
                 players[p].transform.position = Vector3(0,3,-.6);
             }
             camera.useGravity = false;
             camera.transform.position = Vector3(0, 0, -10);
         }
     }

Now, that works great, as long as there is only one player on the server. The camera goes to the desired location, and remains there until it's triggered again to fall, and the player is put into the right location.

The issue arises when another player connects.

If the player that is hosting presses the "K" key, the array for loop will gather all the GameObjects tagged as a player, and will move them to that position, and the camera will return up, on the server's screen, everything appears to be working fine.

But, only for a fraction of a second, Then, the client player that didn't depress the "K" key will begin bouncing between where they originally rested, and where the script called them too. On the client screen, the camera will still be moving downward, and the server will also be moving from where they were called to back to where they had originally rested. The camera will begin to shake and rubberband back up and down as the difference grows between the client and server.

So, I suppose the problem is, I need to be able to update the players'. and camera's transforms, and the camera settings on both the client and server side, so that the players and camera aren't in two different places on their respective screens. Does anyone know how to do so? A way to make both the client and server follow the same command? Both the players have NetworkView components attached to them, as does the empty object which holds the script I pasted above.

I'm sorry if any part of this was unclear, I'm not the best at articulating. If anyone needs anything cleared up, I can help. Thank you for any help I receive in advance

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Move camera when mouse is near the edges of the screen 1 Answer

Need help updating camera position to go above the player 2 Answers

(C#) Follow target (script) transform target PREFAB 0 Answers

Trouble converting transform.position to C# 1 Answer

Update transform component from server every frame 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