- Home /
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
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
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?
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;
}
}
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! ;)
Answer by TheCodeCrafter · May 15, 2017 at 02:38 PM
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?
Your answer
Follow this Question
Related Questions
Warp drive and sound on key press 0 Answers
Smooth Space Flight Script 1 Answer
Weapons Range Projectile script 1 Answer
How do i keep an object from rotating? 2 Answers
Ship movement in space-based RTS 0 Answers