• 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
2
Question by Charlie_Haslam · Jan 03, 2015 at 06:04 PM · spaceflightshipbuilder

Creating A Ship Customisation/Building System

We are currently working on a 3d (first person) flight/shooter game set in space.

We want players to be able to build and customise their own ships using a selection of parts they "purchase" using money earned form playing matches. The idea is to build up a bank of weapons, armour, cockpits and utilities which they then arrange however they want in some kind of in-game builder. Sort of like Kerbal Space Program or Spore.

We aren't sure how to tackle this and what sort of infrastructure we need to make this. Maybe have the separate parts they have unlocked as prefabs and then instantiate them in some way where the player wants them and then find a way of connecting all the parts together once they have finished placing them?

We code in C# but can use Java, so C# is preferable if quoting any scripts. If anyone could link me some practical examples or tutorials that cover part of this that would be great! Thanks, Charlie HasALamb Games

Comment
Add comment · Show 2
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 kieyard · Jun 19, 2016 at 01:12 PM 0
Share

Hello, I was just wondering if you managed to make the building system? And if you did, could you perhaps help me with the same problem be sending me a copy of the code or letting me know the way you went about it? Thanks $$anonymous$$ieran

avatar image TheCodeCrafter · May 15, 2017 at 12:36 PM 0
Share

@jdean300

Could you add a bit more to your code, I am very interested in this, and I am kind of new to Unity, but not program$$anonymous$$g. I know that your time is likely valuable, but could you possibly make a demo for me to work off of?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jdean300 · Jun 19, 2016 at 04:57 PM

Yes, each piece should likely be a prefab.

You would have some kind of UI that would have each of the parts shown on screen that the players could drag around and place on their objects. You'd have a root player ship object that you could then attach child objects to:

 GameObject playerShip = /*get a reference to the player's ship somehow*/;
 GameObject subObject = (GameObject) Instantiate(shipPiecePrefab, pos, rot);
 
 subObject.transform.parent = playerShip;

To keep track of what objects a players ship has you could use a Dictionary. The GameObject in this dictionary would be the prefabs themselves, not the instances attached to the player's ship, and the Vector3 would be the objects position relative to the parent. This way you could instantiate multiple copies of this ship (in-world, ship building screen, etc.). Could be something like this

 //Think of this as a blueprint from which to create the players ship
 public class PlayerShipSetup : MonoBehaviour
 {
     //Populated from your ship building UI
     public Dictionary<GameObject, Vector3> ShipPieces;
 
 
     //Instantiate the ship using the required pieces
     public GameObject BuildShip()
     {
         var playerShip = new GameObject();
         foreach (var shipPiece in ShipPieces)
         {
             var p = (GameObject) Instantiate(shipPiece.Key, shipPiece.Value, Quaternion.identity);
             p.transform.SetParent(playerShip.transform, false);
         }
         return playerShip;
     }
 }



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 TheCodeCrafter · May 15, 2017 at 12:37 PM 0
Share

Hey, could you elaborate? Or possibly make a demo game? I really need some help, as I'm new to Unity, but not C# or Program$$anonymous$$g. Could you help? I know your time is probably valuable, but I need some guidance! ;)

avatar image
0

Answer by TheCodeCrafter · May 15, 2017 at 02:38 PM

@jdean300

Could you add a bit more to your code, I am very interested in this, and I am kind of new to Unity, but not programming. I know that your time is likely valuable, but could you possibly make a demo for me to work off of?

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

6 People are following this question.

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

Related Questions

Space Flight Script 1 Answer

Glow effects and bg texture? 1 Answer

Space fighter banking 1 Answer

Good prefab/assest to buy for FPS style shooter iOS? 0 Answers

Fly-By-Wire System 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