Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 BeastBurst · Apr 21 at 08:56 AM · c++exporting

How to export unity terrain and gameobjects and import them in C++ server?

Hello,

we are using Unity for building our game client making a multiplayer game. Our server however is written in C++ for obvious performance reasons.

I would like to ask the community if you guys know any tool/library which can allow me to export the terrain in some format and then build myself a logic to import it in C++ in our server.

For example maybe I can export the terrain as OBJ and import in in our C++ server via OpenGL?

Can you suggest any other better/easier approach ?

I need that to act as authoritative solution. For example when player 1 is shooting at player 2 I want to see if there isn't any wall between them.

I am really open for suggestions.

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
0

Answer by Pangamini · Apr 21 at 12:21 PM

So basically you want to recreate the Unity engine (or a part of it at least) in a separate C++ project? But Unity core is written in C++. GameObject itself has no effect on the scene, it's the components that create the behaviour and fill the scene.


What exactly would "exporting the gameobjects to C++" even mean? If you would describe an exact subset of what you want to mirror in your C++ server, it might get more doable. For example, maybe all you need is a list of static box colliders from a scene. Still, you would most likely be getting different results on the client and on the server. In such case, you can either write an editor script that extracts all data you want (eg. find all colliders and write their position and size to a json file) or parse the unity's yaml files directly. Still, you would have to recreate the collision detection (or anything else) in your own C++ project.


While I understand your motivation to mirror the unity behavior in a separate project, I'd suggest that you instead create a headless build from your Unity project to serve as a dedicated server. You can boost the performance by utilizing the powerful IL2CPP build option. To further optimize the server build, you can remove everything that's unneccessary. For example, your server might not need to evaluate character animations (unless of course you want them there for hitbox evaluation). Your server most likely doesn't need to include any graphical assets (unless you want your server to render screenshots and send them to clients or store them in a database), same goes for sound clips etc. In a such a case, you could implement a custom BuildPreprocessor that simply removes any MeshRenderer, MeshFilter, AudioSource, Animator, Camera and other components from all scenes and prefabs, to ensure the server build stays lightweight and doesn't do anything absolutely necessary for the simulation of the game. Use C# conditional compilation to exclude any code related to client-only experience and access to those removed components. Maintain a single project instead of mirroring the same behavior in two that use completely different frameworks. This approach works for me.

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

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

Receiving information from a serial port 7 Answers

Unity integration options 1 Answer

How to teleport the player to the location of an instantiated projectile? 1 Answer

How to create a native OS X plugin from a static C++ .a library 0 Answers

Access Unity Script Function From External Program 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