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 /
  • Help Room /
avatar image
1
Question by Pyotex · Jul 29, 2016 at 10:17 PM · rigidbodytransformnetworksynchronization

Unet rigidbody.AddForce not working for clients

Me and my friend are making a multiplayer survival game and we wanted to add in a boat. We have a script attached on it(BoatMover.cs) and in the PlayerController.cs we check if the user is near a boat and parent the player to it.

In the BoatMover.cs we just check for input and add force accordingly. Everything is fine on the host and the boat is moving but on the client it's a different story. The force is being added to the boat but something else is preventing it from moving. The sync mode on the boat is set to SyncRigidbody3D but when i change it to SyncTransform everything is working, but my boat movement is jittery and it's not the solution to the problem. I don't understand why this is happening and i would appreciate if you could help me. Here is my BoatMover.cs:

   if (keyPressedW)
         {
             rigid.AddForce(transform.right * 500 * Time.deltaTime);
         }
         if (keyPressedS)
         {
             rigid.AddForce(-transform.right * 500 * Time.deltaTime);
         }
         if (keyPressedD) {
             rigid.AddTorque(transform.up * 200 * Time.deltaTime);
         }
         if (keyPressedA)
         {
             rigid.AddTorque(-transform.up * 200 * Time.deltaTime);
         }

Thanks 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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Firedan1176 · Jul 30, 2016 at 12:06 AM

I would suggest syncing Transforms. There are a few occasions where syncing rigidbodies would be the best choice. In an FPS game, syncing rigidbodies may not always be accurate. The player may be a few millimeters off, but it could affect gameplay. There may also be times where players will glitch through or spasm out because of these small differences.

When syncing Transforms, you're sending the exact coordinate of where the GameObject should be. Therefore, it's going to update it. This is exactly what it's supposed to do.

The better solution is to not directly set the position on the other person's client. What you want to do is take that into a lerp function. Something like this:

transform.position = Vector3.Lerp(transform.position, targetPosition, 3 * Time.deltaTime);

You will want to play with the '3'. Also note that targetPosition would be the Transform that the player should go to (the Transform value you are sending to the other client).

If you have questions, let me know.

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 Pyotex · Jul 31, 2016 at 01:23 PM 0
Share

That fixed this problem but generated lots of other problems, and we really need to use rigidbody sync because of other scripts. Do you have any other suggestions?

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

88 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sync weapon switching uNET. 0 Answers

rigidybody transform rotation & position mutually exclusive? 0 Answers

How to Make A Character Stop At Wall? 0 Answers

Multiplayer Ragdoll not synchronizing! 1 Answer

Move a RigidBody with MovePosition up and down 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