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
1
Question by Korahan · Oct 01, 2017 at 01:05 PM · networkingproceduraltilessync

Syncvar on procedural tiles

Hello, everyone, it's my first attempt on designing a multiplayer game.

I have a working lobby, the players are in sync as well.

The hex tile gameworld is defined (size, random seed ...) in the lobby. Every client then generates the same world. Here is the problem: If I change a variable on one of the tiles (for example the integer representing the climate), the change remains local. I have used Syncvar which works fine for anything else but the tiles.

I guess every player has a similar looking gameworld but because of the way I generate them, the tiles are all local? What is the best way to synchronize them?

 GameObject hex_go = (GameObject)Instantiate (hexPrefab, new Vector3 (xPos, 0, y * zOffset), Quaternion.identity);

 
Comment
Add comment · Show 4
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 shrey150 · Oct 01, 2017 at 06:04 PM 0
Share

I know this doesn't directly solve the problem, but why not make the server decide on start up, a random "seed" to use? This seed is then synced (as a SyncVar or something) and recreated on the clients. It sounds way easier than syncing over a whole map imo

avatar image Korahan shrey150 · Oct 01, 2017 at 07:27 PM 0
Share

Sorry, I'm not as good at expressing myself in English as I'd wish to be. :-/

At the moment, the seed is assigned/generated by the host of the game or will be randomly chosen if it is a dedicated server. Afterwards, it is shared to all clients. There is a map generator game object in my scene which takes that seed for generating the map. So, if I understand you correctly, it already is the way you suggested and every player already starts with the identical map. The problem I have occurs during gameplay when players change the terrain. The changes they make are not synced although all corresponding variables are syncvar integers.

avatar image shrey150 Korahan · Oct 01, 2017 at 11:20 PM 0
Share

O$$anonymous$$G I'm an idiot I totally didn't see that... this is why I shouldn't just quickly reply to a question xD Your english is really good BTW, I didn't even realize you weren't a native speaker.

I do have one idea for your problem then. If I assume that your SyncVars are for the 3D coordinates and other such things, you may need to use a hook function to sync the changes. Something like this:

 [SyncVar(hook="updateTerrain")]
 float xValue;
 
 void updateTerrain(float value) {
 
     transform.position += new Vector3(value, 0, 0);
 
 } 

I haven't tested this or anything, but its an idea. Tell me if it works, and good luck!

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Korahan · Oct 02, 2017 at 08:05 PM

I was finally able to solve the problem.

The map is generated on the server only now. When the map is completed, it is spawned by some very simple code:

     foreach (GameObject tile in tiles) {
             NetworkServer.Spawn (tile);
         }

I also changed all player actions to commands. The server is now changing tiles if necessary and shares the information by the use of SyncVars.

After I figured it out, it seems quite obvious and easy to me and I feel capable to finish the development. But first I have to call my friends - it's time for them to suffer ... <^;..;^>

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

104 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 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

Networking: how to sync complex objects 0 Answers

Syncing times 0 Answers

Procedural terrain bug? 1 Answer

Procedural generation of dungeons with rooms made in the new tile map system? 0 Answers

Syncing audio clips to speech or audio waveform. 0 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