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 Semni · Mar 16, 2017 at 08:25 PM · networkingmultiplayervehiclevehicles

Best practices for multiplayer multi crew vehicles.

I've been looking around for some advice on how to implement multi-crew vehicles in multiplayer within Unity. Basically vehicles that exist as their own entity and players can hop in and out of positions on the vehicle to drive/shoot/etc. The advice I've found so far is very thin on the ground, vague, very outdated or refers to something in the assetstore ( that may or may not still exist ).

I've run pretty solidly up against the limits of my understanding of Unity multiplayer.

I've put together a reasonably functional implementation in singleplayer but I have no idea how to convert that into something that works within the constraints of multiplayer. For example, this is the current setup that I have:

 Player(PlayerControllerScript)
 Vehicle(VehicleControllerScript)
     Driver(DriverScript)(TriggerCollider)
     Gunner(GunnerScript)(TriggerCollider)

When the player hits a key when inside the trigger area of the driver/gunner the Player object becomes a child of the Driver/Gunner and is disabled, the driver script then takes over processing input from the player.

 Vehicle(VehicleControllerScript)
     Driver(DriverScript)(TriggerCollider)
              Player(PlayerControllerScript)
     Gunner(GunnerScript)(TriggerCollider)

This works great in singleplayer but I have no idea how to pass input from the client to the server to tell it to move the player around. Am I at all on the right track or is there a much easier way of implementing this sort of thing?

Your input is much appreciated.

Comment
Add comment · Show 1
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 Random_Peon · Jul 11, 2018 at 11:33 AM 0
Share

Hi there @Semni I'm currently trying to achieve something like you, but have been unsuccessful so far. Have you manage to find a stable way to do this ?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Strixie13 · Jul 11, 2018 at 09:06 PM

Sounds like you are on the right track. Not sure about the high level API, but these are some steps I would generally use for writing a low level protocol.

  • Player 1 parents their controller object to the vehicle object in their scene

  • Server tells everyone to parent the player driving to the vehicle in their scene +(Now in everyone's instance of the game, player 1 is parented to the vehicle object)

  • The player driving now uses vehicle controls -- just like an offline game -- which moves the vehicle in their scene.

  • The person driving keep sending their position to the server as normal

  • The server should know that player X is now driving the vehicle -- they should take that players position and relay it to the other clients as the vehicles position instead.

  • If you had other people join in they would parent the same way to the vehicle object.

  • But their movement would no longer be transmitted (except maybe rotations), since their character is receiving their movement as a child of the vehicle object.

  • Basically, get all the people parented to the vehicle object, and then the server is treating any positions from the person driving as the vehicles position.

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

7 People are following this question.

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

Related Questions

Unity networking tutorial? 6 Answers

Networking server authoritative player input 0 Answers

Networking GameManager/GameState Sync 1 Answer

OnSerializeNetworkView Doesn't work Until Owner moves the Object! 0 Answers

UNet Network Transform not Sync 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