This article is fromInspoy miscellaneous collection | food chicken inspoy learning record
The previous cocos to Unity series was a mess
preface
I was trying to make games with Unity, and I encountered a lot of various problems, which I was trying to solve. The results so far are obvious: the main flow is universal and now allows multiple players to move, turn, and cast skills in the same scene at the same time; The server can also properly synchronize the information of each player to everyone. But the problem more and more, because now the network communication mechanism, always appears puzzling network disconnection, and disconnect is that the client receives the response of channel, the client can still sent to the server, the server can also be received, and return the results to the client normally, of course, but here the client won’t accept it. Another scenario: the current synchronization mechanism is that the client simulates logic and motion separately, and the server is only responsible for synchronizing their location. One player informs the server of his location, and the server broadcasts his location to all other players. This will have a problem, as a result of the existence of network delay, different players see scenes of the situation is different, and now also not released for skills of ejecta synchronously, the fireball attack is also a client to use their judgment, and different client’s judgment result is likely to be different, it is hard to optimize again, The client is only responsible for sending instructions and displaying the location information pushed by the server. The client does not move when it moves. Only when the instruction information transmitted to the server is processed, the server pushes the location change to the client
A new pit
This time, I decided to open source. I will try my best to keep up with the actual development progress. Part of the code will be posted in the article, and the complete code can be found on Github. Of course, at present, it is still difficult to make a complete game. The main problem is that there is no art, no art, and no art orz. Anyway, the main purpose of this project is to learn art resources. Surging ゃ, converse Japanese airways ね~
Create a project
To create a New Unity project (I’m using unity’s latest stable version 5.5.2 F1 at this point), first make some Settings for version control: Go to Edit->Project Settings->Editor to find Version Control-mode and select Visible Meta Files. Asset Serialization-mode = Force Text
Then go to Edit->Project Settings->Player and check Run In Background
The directory structure
This can be decided according to personal habits. My project is as follows:
Assets - Assets root directory | - Resources - may need to be dynamically loaded in your application Resources | | - Prefabs - save all the default body - Views - the default body of each UIView, The MVP M part of the structure of the UI | | - Materials - material - Scenes - | | - Scripts - c # script game scene - the Conf - associated configuration, Including Data and Utils | - the Entity - game scenario various types of entities, such as role, Fireball | | - Event - Event system - Gameplay - logic game related | - Network - Network communication related | - UI - MVP VP part of the structure of the UI | - Editor - the Editor extensions
The complete code
The code snippet posted above only contains key parts due to space limitations, the full code can be found on my Github